Job decoding logic
Project description
Informatics Matters Data Manager Job Decoder
A package that simplifies the decoding of encoded text strings. Given an encoded string the decode() method returns the decoded value or an error.
For example, given the following jinja2 encoded string '{{ foo }}, bar={{ bar }}, baz={{ baz }}' and variable map {'foo': 1, 'bar': 2, 'baz': 3} the decoder returns the string 'foo=1, bar=2, baz=3'.
The following encoding/decoding formats are supported: -
jinja2 (3.0)
The package also provides validate_job_schema() and validate_manifest_schema() functions, which can (should) be used to validate the Manifests and Job definitions against the built-in schemas.
Installation (Python)
The Job decoder is published on PyPI and can be installed from there:
pip install im-data-manager-job-decoder
Once installed you can validate the definition (expected to be a dictionary formed from the definition YAML file) with:
>>> from decoder import decoder >>> error: Optional[str] = decoder.validate_manifest_schema(manifest) >>> error: Optional[str] = decoder.validate_job_schema(job_definition)
And you can decode encoded fields within the job definition. Here we’re decoding the job’s ‘command’ using a map of variables and their values:
>>> decoded, success = decoder.decode(definition['command'], variables, 'command', decoder.TextEncoding.JINJA2_3_0)
A method also exists to generate a Data Manger Job documentation URL for the supported repository types. For example, to get the auto-generated documentation URL for a job definition hosted in a GitHub repository you can do this:
>>> doc_url: str = decoder.get_job_doc_url("github", collection job_id, job_definition, manifest_url)
We support github and gitlab as repository types.
Get in touch
Report bugs, suggest features or view the source code on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file im_data_manager_job_decoder-2.1.0.tar.gz
.
File metadata
- Download URL: im_data_manager_job_decoder-2.1.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11ce891837c7e152be241caac137df192764c06cf2ab6ce84890825bb8c12d25 |
|
MD5 | 042c57e40a855fc4bd546155d2ab233c |
|
BLAKE2b-256 | a021aab821a8f37322d25a92336c56eb5285f13cf3a11b0ec96a0229833f6b04 |
File details
Details for the file im_data_manager_job_decoder-2.1.0-py3-none-any.whl
.
File metadata
- Download URL: im_data_manager_job_decoder-2.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4eefdbdf3d7f5ccb9e154f1d737ca4d25f31e74a94d3a620c71a3752c49d4f8 |
|
MD5 | 1514874fbc16c6fb997b8ab18c0e07c4 |
|
BLAKE2b-256 | 5d596b9d3815145f51f860703ca4785375c6f6ab9204b38ab694d6ef4cda15d7 |