im-data-manager-job-decoder


Nameim-data-manager-job-decoder JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/informaticsmatters/squonk2-data-manager-job-decoder
SummaryJob decoding logic
upload_time2024-04-11 16:31:23
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/95/b3/905d74e176e57b1e703c936170101b8dacae52ec843b67cd619cc5834b94/im-data-manager-job-decoder-2.0.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.0.0",
    "project_urls": {
        "Homepage": "https://github.com/informaticsmatters/squonk2-data-manager-job-decoder"
    },
    "split_keywords": [
        "jinja2",
        "decoder"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a784723da417bdd242aa09868913893b3653386955ab33b51f38dc48a897939e",
                "md5": "d39b083db146bc679665ea7262e9aa50",
                "sha256": "646e712ed1208d9612cef29482a291c89af960a185c8b516fda4d4afac1f1728"
            },
            "downloads": -1,
            "filename": "im_data_manager_job_decoder-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d39b083db146bc679665ea7262e9aa50",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 12473,
            "upload_time": "2024-04-11T16:31:22",
            "upload_time_iso_8601": "2024-04-11T16:31:22.030250Z",
            "url": "https://files.pythonhosted.org/packages/a7/84/723da417bdd242aa09868913893b3653386955ab33b51f38dc48a897939e/im_data_manager_job_decoder-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "95b3905d74e176e57b1e703c936170101b8dacae52ec843b67cd619cc5834b94",
                "md5": "08b7546dfddb8dbde187f37d02fba842",
                "sha256": "72248502803692461169293fd18b041fc54deb13ebece873a99072c672561729"
            },
            "downloads": -1,
            "filename": "im-data-manager-job-decoder-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "08b7546dfddb8dbde187f37d02fba842",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 15688,
            "upload_time": "2024-04-11T16:31:23",
            "upload_time_iso_8601": "2024-04-11T16:31:23.239287Z",
            "url": "https://files.pythonhosted.org/packages/95/b3/905d74e176e57b1e703c936170101b8dacae52ec843b67cd619cc5834b94/im-data-manager-job-decoder-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-11 16:31:23",
    "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: 0.26432s