saas-api-python includes a file .pre-commit-config.yaml
.
The following command installs the pre-commit hooks, see also framework pre-commmit and Git documentation on Customizing Git Git Hooks:
poetry run pre-commit install
When the hooks are installed, then git will run each of the hooks on the resp. stage, e.g. before executing a commit.
The model layer of this API has been generated from the OpenAPI specification in JSON format of the SaaS API https://cloud.exasol.com/openapi.json using openapi-python-client.
See also API Documentation and Swagger UI.
In order to regenerate the model layer please use the following command line:
poetry run nox generate-api
If you want to retrieve the JSON definition for the API model from a different source then just edit file noxfile.py
.
Use CLI option --path
to read the JSON definition from a local file instead of a URL:
"--path", "/path/to/openapi.json",
openapi-python-client reads the JSON specification of the SaaS API and generates a python client. The generated client code requires transitive dependencies, though, which need to be added to file pyproject.toml
to make them available for dependents of SAPIPY.
The easiest way is to make openapi-python-client create a dedicated file pyproject.toml
and copy the transitive dependencies from there to SAPIPY's file pyproject.toml
.
In order to create file pyproject.toml
- In file
noxfile.py
, functiongenerate_api
you need to replace modeupdate
bygenerate
. - Additionally, in file
openapi_config.yml
you need to specify a non-existing top-level directory asproject_name_override
and a package that does not contain slashes, e.g.
project_name_override: "generate"
package_name_override: saas.client.openapi
post_hooks: []
After generating the API,
- Copy the dependencies from file
generate/pyproject.toml
and - Remove directory
generate
.
Executing the integration tests requires the following environment variables to be set:
Variable | Description |
---|---|
SAAS_HOST |
Host to use for requests to REST API |
SAAS_ACCOUNT_ID |
ID of the Exasol SAAS account to be used by the tests |
SAAS_PAT |
Personal access token to access the SAAS API |
Some of the test cases verify connecting to a SaaS database instance and execution will take about 20 minutes.
The regular CI build will ask for a confirmation (aka. "review) before executing these tests.
There are two scenarios for preparing a release:
In both scenarios the SAPIPY relies on Exasol's python-toolbox for preparing a release.
The invocation depends on your setup:
- When working in a poetry shell, you need to add one double-dash
--
argument to separate arguments to the nox-sessionprepare-release
. - When calling
poetry
directly for one-time usage, then you need to add two double-dashes-- --
to terminate arguments to poetry and nox before arguments to the nox-session.
poetry run nox -s prepare-release -- -- <version>
Note that this scenario requires all your changes to be merged to branch main
and no uncommited changes to be present in your local file tree.
Nox session prepare-release
will
- Create a branch, e.g.
prepare-release/1.2.3
starting frommain
- Checkout this new branch
- Update the version in files
pyproject.toml
andversion.py
- Update changes documentation
- Rename file
doc/unreleased.md
todoc/changes_<version>.md
and add the current date as date of the release - Create a new file
doc/unreleased.md
- Update the file
doc/changelog.md
- Rename file
- Commit and push the changes
- Create a pull request on GitHub
Please note that creating a pull request on GitHub requires
- Executable
gh
to be installed and in your$PATH
variable - You must be authenticated towards GitHub via gh, use
gh auth
for that - In case you are using a GitHub token, the token must have permission
org:read
If you prefer to create the pull request manually or cannot provide one of the prerequisites, you can add command line option --no-pr
:
poetry run nox -s prepare-release -- -- <version> --no-pr
In case you currently are already working on a branch other than main
, please ensure to have all changes commited and add command line option --no-branch
:
poetry run nox -s prepare-release -- -- <version> --no-pr --no-branch
When all workflows triggered by merging the pull request to main
have succeeded, you can create a new release by
- Switching to branch
main
- Creating a git tag and
- Pushing it to
origin
TAG="${1}"
git tag "${TAG}"
git push origin "${TAG}"
This will trigger additional GitHub workflows
- Running some checks
- Creating a GitHub release on https://github.com/exasol/saas-api-python/releases and
- Publishing the release on pypi