Developing a Transform Project
This guide assumes you have deployed your Transform project and downloaded your Transform git repo to your local machine. If you have not completed these steps, check out the deployment guide.
First, open a new terminal window and navigate to your Transform directory. We have a CLI interface that will allow you to query metrics from your Transform server. You can read more about the CLI interface here.
We recommend installing the Transform CLI in a virtual environment to avoid any python environment dependency issues.
Run the following commands to set up a virtual environment and activate it. If you don't want to check your virtual environment into git, you can add the directory to your .gitignore file.
python3 -m venv venv && source venv/bin/activate
Next, install Transform.
pip install transform
Finally, you need to authenticate to your Transform server. Run the following command and follow the prompts in your terminal. You will need your Transform API key for this step. You can view and manage your Transform API keys here.
mql setup
To view the available commands for the CLI run
mql --help
You should now be ready to query metrics and develop Transform locally.
Getting Started on the Transform CLI Workflow with Transform
Organization of your Transform repo
As long as you are within the overarching repo folder that contains the relevant YAML files to build the Transform model, you can organize your YAML files however you would like (e.g. different subfolders to break out metrics and data sources). You cannot, however, have other non-Transform YAML files present in the repo (think of the Transform repo as THE model that looks "down" at all levels beneath it. For more context, see the Transform Model.)
CLI Workflow with Transform
Navigate to the repo that holds the YAML files of your Transform model. Make sure that you have Transform installed, or your virtual environment is activated.
Quick useful commands:
mql identify
: This command helps you identify the current model you are working on + when the model was last updated.
mql list-metrics
: This command lists the metrics in your Transform model
mql list-dimensions
: This command lists the dimensions available to your metric(s)
- ex: I want to know all available dimensions in the metric named active_user.
- The CLI command is
mql list-dimensions --metric-names active_user
- The CLI command is
- ex: I want to know all available dimensions for metrics active_user and inactive_user.
- The CLI command is
mql list-dimensions --metric-names active_user,inactive_user
- Note that
list-dimensions
gives you the common dimensions between your metrics of interest.
- The CLI command is
The general workflow to edit, test, and make changes to your Transform model:
- Switch to your relevant github branch
- Make your edits to the appropriate YAML files
mql commit-configs --config-dir .
- This step validates the YAML files in your current directory (specified via
--config-dir .
), checking for syntax errors and incorrect parameters. - When you commit configs, you will be asked whether you want to pin your model (enter
y
for yes,n
for no). Pinning a model means that you are now running a "local" Transform model with your changes. Once your model is pinned, you can now query against your local model. For a quick tutorial on querying, see the MetricFlow tutorial (Transform customers will use themql
command, and notmf
). - You may also include
--skip-dw
to skip validating against your warehouse to check if columns exist (ex:mql commit-configs --skip-dw --config-dir .
)
- This step validates the YAML files in your current directory (specified via
- Once satisfied, you can push your changes to your git repo, and merge your branch.
- For Transform customers: once your changes are merged into the GitHub Repo, the GitHub Actions will automatically trigger to update the model on the Transform app. Once the Github Actions finish, the updated model should also be reflected in the Transform App.
- Remember to unpin your model via
mql unpin-model
(once unpinned, your local configuration will point to whatever is the repo's last-updated model).- Tip:
mql identify
will show you the current model you are on via model ID, as well as the timestamp as to when the model was updated.
- Tip: