Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added dist/python_tabular-0.0.90-py3-none-any.whl
Binary file not shown.
Binary file added dist/python_tabular-0.0.90.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/Best Practice Analyzer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


## BPA
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/best_practice_analyzer.py\#L34)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/best_practice_analyzer.py\#L35)
```python
BPA(
File_Path: str = 'Default'
Expand All @@ -18,7 +18,7 @@ Setting BPA Class for future work...


### Download_BPA_File
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/best_practice_analyzer.py\#L8)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/best_practice_analyzer.py\#L9)
```python
.Download_BPA_File(
Download_Location: str = 'https: //raw.githubusercontent.com/microsoft/Analysis-Services/master/BestPracticeRules/BPARules.json',
Expand Down
39 changes: 36 additions & 3 deletions docs/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


### Return_Zero_Row_Tables
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/basic_checks.py\#L8)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/basic_checks.py\#L9)
```python
.Return_Zero_Row_Tables(
model: pytabular.Tabular
Expand All @@ -27,7 +27,7 @@ Returns list of table names of those that are returning isna()


### Table_Last_Refresh_Times
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/basic_checks.py\#L22)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/basic_checks.py\#L23)
```python
.Table_Last_Refresh_Times(
model: pytabular.Tabular, group_partition: bool = True
Expand Down Expand Up @@ -56,7 +56,7 @@ If group_partition == True and the table has multiple partitions, then df.groupb


### BPA_Violations_To_DF
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/basic_checks.py\#L50)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/basic_checks.py\#L51)
```python
.BPA_Violations_To_DF(
model: pytabular.Tabular, te2: str, bpa: str
Expand All @@ -78,3 +78,36 @@ Runs BPA Analyzer from TE2 and outputs result into a DF.

* **DataFrame** : Super simple right now. Just splits into two columns.. The object in violation and the rule.


----


### Last_X_Interval
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/basic_checks.py\#L67)
```python
.Last_X_Interval(
Model: pytabular.Tabular, Measure: Union[str, pytabular.pytabular.Measure],
Column_Name: Union[str, None] = None,
Date_Column_Identifier: str = "'Date'[DATE_DTE_KEY]",
Number_Of_Intervals: int = 90, Interval: str = 'DAY'
)
```

---
Pulls the Last X Interval (Ex Last 90 Days) of a specific measure.


**Args**

* **Model** (pytabular.Tabular) : Tabular Model to perform query on.
* **Measure** (Union[str,pytabular.pytabular.Measure]) : Measure to query. If string, will first check for a measure in the model with that name, otherwise will assume it is a DAX Expression (Ex SUM(FactTable[ColumnValue]) ) and perform that as expression
* **Column_Name** (Union[str,None], optional) : Column Name to be outputted in DataFrame. You can provide your own otherwise will take from the Measure Name. Defaults to "Result".
* **Date_Column_Identifier** (str, optional) : Date column dax identifier. Defaults to "'Date'[DATE_DTE_KEY]".
* **Number_Of_Intervals** (int, optional) : This is used to plug in the variables for [DATESINPERIOD](https://docs.microsoft.com/en-us/dax/datesinperiod-function-dax). Defaults to 90.
* **Interval** (str, optional) : Sames as Number_Of_Intervals. Used to plug in parameters of DAX function [DATESINPERIOD](https://docs.microsoft.com/en-us/dax/datesinperiod-function-dax). Defaults to "DAY". Possible options are "DAY", "MONTH", "QUARTER", and "YEAR"


**Returns**

* **DataFrame** : Pandas DataFrame of results.

34 changes: 30 additions & 4 deletions docs/Logic Utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


### ticks_to_datetime
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/logic_utils.py\#L11)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/logic_utils.py\#L12)
```python
.ticks_to_datetime(
ticks: int
Expand All @@ -27,7 +27,7 @@ Converts a C# System DateTime Tick into a Python DateTime


### pandas_datatype_to_tabular_datatype
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/logic_utils.py\#L22)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/logic_utils.py\#L23)
```python
.pandas_datatype_to_tabular_datatype(
df: pd.DataFrame
Expand All @@ -52,7 +52,7 @@ WiP takes dataframe columns and gets respective tabular column datatype. ([NumP


### pd_dataframe_to_m_expression
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/logic_utils.py\#L76)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/logic_utils.py\#L77)
```python
.pd_dataframe_to_m_expression(
df: pd.DataFrame
Expand Down Expand Up @@ -94,7 +94,7 @@ Source


### remove_folder_and_contents
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/logic_utils.py\#L120)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/logic_utils.py\#L121)
```python
.remove_folder_and_contents(
folder_location
Expand All @@ -109,3 +109,29 @@ Internal used in tabular_editor.py and best_practice_analyzer.py.

* **folder_location** (str) : Folder path to remove directory and contents.


----


### remove_suffix
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/logic_utils.py\#L132)
```python
.remove_suffix(
input_string, suffix
)
```

---
Adding for >3.9 compatiblity. (Stackoverflow Answer)[https://stackoverflow.com/questions/66683630/removesuffix-returns-error-str-object-has-no-attribute-removesuffix]


**Args**

* **input_string** (str) : input string to remove suffix from
* **suffix** (str) : suffix to be removed


**Returns**

* **str** : input_str with suffix removed

6 changes: 3 additions & 3 deletions docs/Tabular Editor 2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


## Tabular_Editor
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/tabular_editor.py\#L38)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/tabular_editor.py\#L39)
```python
Tabular_Editor(
EXE_File_Path: str = 'Default'
Expand All @@ -18,7 +18,7 @@ Setting Tabular_Editor Class for future work.


### Download_Tabular_Editor
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/tabular_editor.py\#L8)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/tabular_editor.py\#L9)
```python
.Download_Tabular_Editor(
Download_Location: str = 'https: //github.com/TabularEditor/TabularEditor/releases/download/2.16.7/TabularEditor.Portable.zip',
Expand All @@ -39,5 +39,5 @@ Runs a request.get() to retrieve the zip file from web. Will unzip response and

**Returns**

* **str** : _description_
* **str** : File path of TabularEditor.exe

66 changes: 38 additions & 28 deletions docs/Tabular.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


## Tabular
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L22)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L26)
```python
Tabular(
CONNECTION_STR: str
Expand All @@ -16,15 +16,15 @@ Tabular Class to perform operations: [Microsoft.AnalysisServices.Tabular](https:

**Args**

* **CONNECTION_STR** (str) : [Connection String](https://docs.microsoft.com/en-us/analysis-services/instances/connection-string-properties-analysis-services?view=asallproducts-allversions)
* **CONNECTION_STR** (str) : Valid [Connection String](https://docs.microsoft.com/en-us/analysis-services/instances/connection-string-properties-analysis-services?view=asallproducts-allversions) for connecting to a Tabular Model.



**Methods:**


### .Reload_Model_Info
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L54)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L58)
```python
.Reload_Model_Info()
```
Expand All @@ -39,7 +39,7 @@ Runs on __init__ iterates through details, can be called after any model changes


### .Disconnect
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L65)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L70)
```python
.Disconnect()
```
Expand All @@ -54,26 +54,42 @@ Disconnects from Model


### .Refresh
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L80)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L78)
```python
.Refresh(
Object: Union[str, Table, Partition, Iterable], RefreshType = RefreshType.Full,
Run: bool = True
Object: Union[str, Table, Partition, Dict[str, Any]],
RefreshType: RefreshType = RefreshType.Full, Tracing = False
)
```

---
Input Object(s) to be refreshed in the tabular model. Combine with .SaveChanges() to actually run the refresh on the model.
Refreshes table(s) and partition(s).


**Args**

* **Object** (Union[str,Table,Partition,Iterable]) : Can be str(table name only), Table object, Partition object, or an iterable combination of the three.
* **RefreshType** (_type_, optional) : [RefreshType](https://docs.microsoft.com/en-us/dotnet/api/microsoft.analysisservices.tabular.refreshtype?view=analysisservices-dotnet). Defaults to RefreshType.Full.
* **Object** (Union[ str, Table, Partition, Dict[str, Any], Iterable[str, Table, Partition, Dict[str, Any]] ]) : Designed to handle a few different ways of selecting a refresh.
* **RefreshType** (RefreshType, optional) : See [RefreshType](https://docs.microsoft.com/en-us/dotnet/api/microsoft.analysisservices.tabular.refreshtype?view=analysisservices-dotnet). Defaults to RefreshType.Full.
* **Tracing** (bool, optional) : Currently just some basic tracing to track refreshes. Defaults to False.
str == 'Table_Name'
Table == Table Object
Partition == Partition Object
Dict[str, Any] == A way to specify a partition of group of partitions. For ex. {'Table_Name':'Partition1'} or {'Table_Name':['Partition1','Partition2']}. NOTE you can also change out the strings for partition or tables objects.


**Raises**

* **Exception** : Raises exception if unable to find table or partition via string.



**Returns**

* **WIP** : WIP


### .Update
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L110)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L171)
```python
.Update(
UpdateOptions: UpdateOptions = UpdateOptions.ExpandFull
Expand All @@ -95,22 +111,14 @@ Input Object(s) to be refreshed in the tabular model. Combine with .SaveChanges(


### .SaveChanges
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L121)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L182)
```python
.SaveChanges()
```

---
TODO need to clean this up and add more flexibility.
Just a simple wrapper to call self.Model.SaveChanges()


**Returns**

bool:

### .Backup_Table
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L131)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L204)
```python
.Backup_Table(
table_str: str
Expand All @@ -134,7 +142,7 @@ Refresh is performed from source during backup.


### .Revert_Table
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L198)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L271)
```python
.Revert_Table(
table_str: str
Expand Down Expand Up @@ -162,7 +170,7 @@ Example scenario ->


### .Query
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L263)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L336)
```python
.Query(
Query_Str: str
Expand All @@ -175,7 +183,9 @@ Executes Query on Model and Returns Results in Pandas DataFrame

**Args**

* **Query_Str** (str) : Dax Query. Note, needs full syntax (ex: EVALUATE). See https://docs.microsoft.com/en-us/dax/dax-queries
* **Query_Str** (str) : Dax Query. Note, needs full syntax (ex: EVALUATE). See (DAX Queries)[https://docs.microsoft.com/en-us/dax/dax-queries].
Will check if query string is a file. If it is, then it will perform a query on whatever is read from the file.
It is also possible to query DMV. For example. Query("select * from $SYSTEM.DISCOVER_TRACE_EVENT_CATEGORIES"). See (DMVs)[https://docs.microsoft.com/en-us/analysis-services/instances/use-dynamic-management-views-dmvs-to-monitor-analysis-services?view=asallproducts-allversions]


**Returns**
Expand All @@ -184,7 +194,7 @@ Executes Query on Model and Returns Results in Pandas DataFrame


### .Query_Every_Column
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L293)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L377)
```python
.Query_Every_Column(
query_function: str = 'COUNTROWS(VALUES(_))'
Expand All @@ -207,7 +217,7 @@ This will dynamically create a query to pull all columns from the model and run


### .Query_Every_Table
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L315)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L399)
```python
.Query_Every_Table(
query_function: str = 'COUNTROWS(_)'
Expand All @@ -230,7 +240,7 @@ It will replace the _ with the table to run.


### .Analyze_BPA
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L335)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L419)
```python
.Analyze_BPA(
Tabular_Editor_Exe: str, Best_Practice_Analyzer: str
Expand All @@ -255,7 +265,7 @@ Takes your Tabular Model and performs TE2s BPA. Runs through Command line.


### .Create_Table
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L359)
[source](https://github.com/Curts0/PyTabular\blob\master\pytabular/pytabular.py\#L443)
```python
.Create_Table(
df: pd.DataFrame, table_name: str
Expand Down
Loading