Skip to content

Latest commit

 

History

History
69 lines (54 loc) · 3.38 KB

CONTRIBUTING.md

File metadata and controls

69 lines (54 loc) · 3.38 KB

For developers

Prerequisites

You'll need to have poetry installed to manage python dependencies. Instructions for installing poetry can be found here.

To install the CLI locally, run the following commands from the root project directory:

poetry lock      # only needed if you updated dependencies in pyproject.toml
poetry install

You do not need to re-run these commands each time you update code locally, unless you've added dependencies in pyproject.toml.

Developing

If you do update dependencies in pyproject.toml, run poetry lock and check in the resulting changes to poetry.lock along with the rest of your code changes.

If you use an IDE terminal, you can run the following commands from there. To interact with a terminal external to your IDE, first run poetry shell and then you'll be able to run the commands as documented here.

Tests, linters, and formatting

To run tests:

pytest

To run tests with a coverage report printed to the terminal:

pytest --cov-report term --cov=terralab

To run the formatter, execute the following command from the root project directory:

black .

To run the linter with fixes, execute the following command from the root project directory:

ruff check --fix

To run the linter as a check without fixes, omit the --fix flag.

Coordinating changes with the Teaspoons service

Sometimes, updates to Teaspoons will need to be coordinated with updates to the CLI.

To test changes in Teaspoons locally against your local CLI, do the following once you've made changes in your local code and are ready to test them:

  1. Follow the instructions in the Teaspoons repo for creating the autogenerated Python client locally.
  2. In this repo, edit the pyproject.toml file as follows: comment out the line that defines the terra-scientific-pipelines-service-api-client dependency, and add a line like teaspoons-client = {path = "YOUR/LOCAL/PATH/TO/terra-scientific-pipelines-service/python-client/generated"} It should look something like this:
teaspoons-client = {path = "/Users/awesomedeveloper/workbench/terra-scientific-pipelines-service/python-client/generated"}
# terra-scientific-pipelines-service-api-client = "^0.1.0"
  1. Run poetry update. (This is equivalent to running poetry lock and then poetry install.)

Your CLI should now be importing the teaspoons_client via the local code rather than the package from PyPi.

Note: if the locally generated code is not being imported as expected, try deleting and recreating the poetry virtual environment by running the following:

rm -rf $(poetry env info --path)
poetry install

To run the CLI against your locally running instance of Teaspoons: 4. Follow the instructions in the Teaspoons repo for running the service locally. 5. In this repo, edit the terralab/.terralab-cli-config file to point the TEASPOONS_API_URL to http://localhost:8080 instead of the live environment deployment of Teaspoons. 6. That's it! Run your CLI commands and test until you're confident it's all working as you'd like.