TabularEditor / TabularEditor

This is the code repository and issue tracker for Tabular Editor 2.X (free, open-source version). This repository is being maintained by Daniel Otykier.
https://tabulareditor.com
MIT License
880 stars 215 forks source link

Download all .json files from Tabular Editor #991

Open lakviat opened 2 years ago

lakviat commented 2 years ago

Hi there.

I'm trying to download all .json measures from the Tabular Editor that reads from power bi (.pbix file) I need to integrate this with CLI so that I can run in CI/CD

The previous issues raised here didn't work for me ( I did researches before raising issue) ''' $cmd = "& ""C:\Program Files (x86)\Tabular Editor\TabularEditor.exe"" ""$Server"" ""$DatabaseName"" -F ""$ModelFolderPath"" " '''

This is the command I came up with :


start "& ""C:\Program Files\Tabular Editor 3\TabularEditor3.exe"" ""$https://dbname.com"" ""$ENTERPRISE_DB"" -F ""$C:\Users\Test"" "


Basically I need to extract all measure .json files from the Tabular Editor from the CLI but none of the options worked for me

I would appreciate the help !

otykier commented 2 years ago

Hi @lakviat In your example, you're using TabularEditor3.exe. This executable does not have a CLI. You should use the .exe from Tabular Editor 2.x instead.

lakviat commented 2 years ago

Thanks getting back to me @otykier

I tried with the version 2 but that didn't work for me, am I missing something ?

command that I'm running :


start /wait "& ""C:\Program Files (x86)\Tabular Editor\TabularEditor.exe"" ""$powerbi://api.powerbi.com"" ""$DB_ID_Number"" -F ""$C:\Users\user_name\Folder"" "


I would appreciate the help here

otykier commented 2 years ago

What error message are you getting?

lakviat commented 2 years ago

@otykier Basically nothing, it opens another CMD terminal and that's it

otykier commented 2 years ago

Okay, I suggest you try to run the command on your local machine in a Windows Command Prompt, to better see what’s going on, before implementing it in a CI/CD pipeline.

lakviat commented 2 years ago

@otykier I'm actually running it locally, I have not implemented it in the CI CD yet

otykier commented 2 years ago

Try to run it without start /wait. It’s difficult to know whats going on if you’re not getting any output.

lakviat commented 2 years ago

@otykier now I'm getting the message


The filename, directory name, or volume label syntax is incorrect (The directory is present thought)


The command I ran


"& ""C:\Program Files (x86)\Tabular Editor\TabularEditor.exe"" ""$powerbi://api.powerbi.com"" ""$DB_NAME"" -F ""$C:\Users\user_name\BigTest"" "


otykier commented 2 years ago

That error message does not originate from Tabular Editor. Let's start over. Here's what I do:

"c:\Program Files (x86)\Tabular Editor\TabularEditor.exe" "localhost" "AdventureWorks" -F "c:\Users\DanielOtykier\Desktop\TestOutputModel"

Here, you would need to replace localhost with the full connection string to the Power BI workspace, including your Service Principal credentials, there's an example here. AdventureWorks is the name of the dataset to load. You should see something like this to indicate that TabularEditor.exe is actually running:

image

lakviat commented 2 years ago

Hi @otykier I was able to generate database.json but I need to extract full set of folders from the model Tried to use serialize options from #652 but that isn't working for me

is there anything I'm missing here ?

"C:\Program Files (x86)\Tabular Editor\TabularEditor.exe" "DataSource=powerbi://api.powerbi.com/;User ID=app:XXXX@XXXX;Password=XXXX" "Labour DEV" "Model.SetAnnotation("TabularEditor_SerializeOptions", ReadFile("C:\Users\nmirovich\TabularEditor_SerializeOptions.json"));" -S "ApplySerializeOptionsAnnotation.csx" -F "C:\Users\nmirovich\BigTest"

I also tried to set the annotations first using Model.SetAnnotation, that didn't work either

"C:\Program Files (x86)\Tabular Editor\TabularEditor.exe" "Model.SetAnnotation("TabularEditor_SerializeOptions", ReadFile("C:\Users\nmirovich\TabularEditor_SerializeOptions.json"));"
otykier commented 2 years ago

Hi @lakviat If you used the ApplySerializeOptionsAnnotation.csx script from #652, you must make sure that the .json file is located in the same folder as your current directory, or fix the path used in the script. Within a script, remember that you have to escape \ characters in strings by typing them twice: \\.

But instead of using the script, I recommend setting the annotation through Tabular Editor's UI. You only need to do this once:

  1. Open Tabular Editor and connect to the Power BI model
  2. Under File > Preferences > Current Model, put a checkmark in "Tables" and "Measures". Click "OK".
  3. Save the model (Ctrl+S). The annotation should now be applied to the model so folder serialization should split the model into files for individual tables and measures.
  4. You can test that the folder serialization works as expected using File > Save to Folder (make sure "Use serialization settings from annotations" is checked).

The next time you use the CLI, you can then simply do this:

"C:\Program Files (x86)\Tabular Editor\TabularEditor.exe" "DataSource=powerbi://api.powerbi.com/;User ID=app:XXXX@XXXX;Password=XXXX" "Labour DEV" -F "C:\Users\nmirovich\BigTest"
lakviat commented 2 years ago

Thanks for the help @otykier

Just to let know "Provider=MSOLAP; was missing from the command for that reason it was not generating folders

works now

lakviat commented 2 years ago

Hi @otykier quick question, have you solved the problem of programmatically downloading the .pbix files from power bi to your CI CD server by any chance ? if so can you share some insights that worked best for you ?