im-data-manager-job-decoder


Nameim-data-manager-job-decoder JSON
Version 2.1.0 PyPI version JSON
download
home_pagehttps://github.com/informaticsmatters/squonk2-data-manager-job-decoder
SummaryJob decoding logic
upload_time2024-07-30 15:38:21
maintainerNone
docs_urlNone
authorAlan Christie
requires_python>=3.10
licenseMIT
keywords jinja2 decoder
VCS
bugtrack_url
requirements jinja2 jsonschema pyyaml
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Informatics Matters Data Manager Job Decoder
============================================

.. image:: https://badge.fury.io/py/im-data-manager-job-decoder.svg
   :target: https://badge.fury.io/py/im-data-manager-job-decoder
   :alt: PyPI package (latest)

.. image:: https://github.com/InformaticsMatters/squonk2-data-manager-job-decoder/actions/workflows/build.yaml/badge.svg
   :target: https://github.com/InformaticsMatters/squonk2-data-manager-job-decoder/actions/workflows/build.yaml
   :alt: Build

.. image:: https://github.com/InformaticsMatters/squonk2-data-manager-job-decoder/actions/workflows/publish.yaml/badge.svg
   :target: https://github.com/InformaticsMatters/squonk2-data-manager-job-decoder/actions/workflows/publish.yaml
   :alt: Publish

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.

.. _jinja2: https://jinja.palletsprojects.com/en/3.0.x/

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.

.. _PyPI: https://pypi.org/project/im-data-manager-job-decoder

Get in touch
============

- Report bugs, suggest features or view the source code `on GitHub`_.

.. _on GitHub: https://github.com/informaticsmatters/squonk2-data-manager-job-decoder

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/informaticsmatters/squonk2-data-manager-job-decoder",
    "name": "im-data-manager-job-decoder",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "jinja2 decoder",
    "author": "Alan Christie",
    "author_email": "achristie@informaticsmatters.com",
    "download_url": "https://files.pythonhosted.org/packages/a0/21/aab821a8f37322d25a92336c56eb5285f13cf3a11b0ec96a0229833f6b04/im_data_manager_job_decoder-2.1.0.tar.gz",
    "platform": "any",
    "description": "Informatics Matters Data Manager Job Decoder\n============================================\n\n.. image:: https://badge.fury.io/py/im-data-manager-job-decoder.svg\n   :target: https://badge.fury.io/py/im-data-manager-job-decoder\n   :alt: PyPI package (latest)\n\n.. image:: https://github.com/InformaticsMatters/squonk2-data-manager-job-decoder/actions/workflows/build.yaml/badge.svg\n   :target: https://github.com/InformaticsMatters/squonk2-data-manager-job-decoder/actions/workflows/build.yaml\n   :alt: Build\n\n.. image:: https://github.com/InformaticsMatters/squonk2-data-manager-job-decoder/actions/workflows/publish.yaml/badge.svg\n   :target: https://github.com/InformaticsMatters/squonk2-data-manager-job-decoder/actions/workflows/publish.yaml\n   :alt: Publish\n\nA package that simplifies the decoding of encoded text strings.\nGiven an encoded string the ``decode()`` method\nreturns the decoded value or an error.\n\nFor example, given the following `jinja2`_ encoded string\n``'{{ foo }}, bar={{ bar }}, baz={{ baz }}'`` and variable map\n``{'foo': 1, 'bar': 2, 'baz': 3}`` the decoder returns\nthe string ``'foo=1, bar=2, baz=3'``.\n\nThe following encoding/decoding formats are supported: -\n\n- jinja2 (3.0)\n\nThe package also provides ``validate_job_schema()`` and\n``validate_manifest_schema()`` functions, which can (should) be used to\nvalidate the Manifests and Job definitions against the\nbuilt-in schemas.\n\n.. _jinja2: https://jinja.palletsprojects.com/en/3.0.x/\n\nInstallation (Python)\n=====================\n\nThe Job decoder is published on `PyPI`_ and can be installed from\nthere::\n\n    pip install im-data-manager-job-decoder\n\nOnce installed you can validate the definition (expected to be a dictionary\nformed from the definition YAML file) with::\n\n    >>> from decoder import decoder\n    >>> error: Optional[str] = decoder.validate_manifest_schema(manifest)\n    >>> error: Optional[str] = decoder.validate_job_schema(job_definition)\n\nAnd you can decode encoded fields within the job definition.\nHere we're decoding the job's 'command' using a map of variables and their\nvalues::\n\n    >>> decoded, success = decoder.decode(definition['command'],\n                                          variables,\n                                          'command',\n                                          decoder.TextEncoding.JINJA2_3_0)\n\nA method also exists to generate a Data Manger Job documentation URL\nfor the supported repository types. For example, to get the\nauto-generated documentation URL for a job definition hosted in a GitHub\nrepository you can do this::\n\n    >>> doc_url: str = decoder.get_job_doc_url(\"github\",\n                                               collection\n                                               job_id,\n                                               job_definition,\n                                               manifest_url)\n\nWe support ``github`` and ``gitlab`` as repository types.\n\n.. _PyPI: https://pypi.org/project/im-data-manager-job-decoder\n\nGet in touch\n============\n\n- Report bugs, suggest features or view the source code `on GitHub`_.\n\n.. _on GitHub: https://github.com/informaticsmatters/squonk2-data-manager-job-decoder\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Job decoding logic",
    "version": "2.1.0",
    "project_urls": {
        "Homepage": "https://github.com/informaticsmatters/squonk2-data-manager-job-decoder"
    },
    "split_keywords": [
        "jinja2",
        "decoder"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5d596b9d3815145f51f860703ca4785375c6f6ab9204b38ab694d6ef4cda15d7",
                "md5": "1514874fbc16c6fb997b8ab18c0e07c4",
                "sha256": "b4eefdbdf3d7f5ccb9e154f1d737ca4d25f31e74a94d3a620c71a3752c49d4f8"
            },
            "downloads": -1,
            "filename": "im_data_manager_job_decoder-2.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1514874fbc16c6fb997b8ab18c0e07c4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 12530,
            "upload_time": "2024-07-30T15:38:19",
            "upload_time_iso_8601": "2024-07-30T15:38:19.833231Z",
            "url": "https://files.pythonhosted.org/packages/5d/59/6b9d3815145f51f860703ca4785375c6f6ab9204b38ab694d6ef4cda15d7/im_data_manager_job_decoder-2.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a021aab821a8f37322d25a92336c56eb5285f13cf3a11b0ec96a0229833f6b04",
                "md5": "042c57e40a855fc4bd546155d2ab233c",
                "sha256": "11ce891837c7e152be241caac137df192764c06cf2ab6ce84890825bb8c12d25"
            },
            "downloads": -1,
            "filename": "im_data_manager_job_decoder-2.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "042c57e40a855fc4bd546155d2ab233c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 15744,
            "upload_time": "2024-07-30T15:38:21",
            "upload_time_iso_8601": "2024-07-30T15:38:21.193426Z",
            "url": "https://files.pythonhosted.org/packages/a0/21/aab821a8f37322d25a92336c56eb5285f13cf3a11b0ec96a0229833f6b04/im_data_manager_job_decoder-2.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-30 15:38:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "informaticsmatters",
    "github_project": "squonk2-data-manager-job-decoder",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "jinja2",
            "specs": [
                [
                    "==",
                    "3.1.3"
                ]
            ]
        },
        {
            "name": "jsonschema",
            "specs": [
                [
                    ">=",
                    "4.21.1"
                ],
                [
                    "<",
                    "5.0"
                ]
            ]
        },
        {
            "name": "pyyaml",
            "specs": [
                [
                    ">=",
                    "5.3.1"
                ],
                [
                    "<",
                    "7.0"
                ]
            ]
        }
    ],
    "lcname": "im-data-manager-job-decoder"
}
        
Elapsed time: 1.70689s