openjd-adaptor-runtime


Nameopenjd-adaptor-runtime JSON
Version 0.8.1 PyPI version JSON
download
home_pageNone
SummaryA python library for building adaptors that integrate applications with Open Job Description jobs.
upload_time2024-11-13 21:21:22
maintainerNone
docs_urlNone
authorAmazon Web Services
requires_python>=3.9
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Open Job Description - Adaptor Runtime

[![pypi](https://img.shields.io/pypi/v/openjd-adaptor-runtime.svg?style=flat)](https://pypi.python.org/pypi/openjd-adaptor-runtime)
[![python](https://img.shields.io/pypi/pyversions/openjd-adaptor-runtime.svg?style=flat)](https://pypi.python.org/pypi/openjd-adaptor-runtime)
[![license](https://img.shields.io/pypi/l/openjd-adaptor-runtime.svg?style=flat)](https://github.com/OpenJobDescription/openjd-adaptor-runtime/blob/mainline/LICENSE)

This package provides a runtime library for creating a command-line Adaptor to assist with
integrating an existing application, such as a rendering application, into batch computing systems
that run Jobs in a way that is compatible with [Open Job Description Sessions]. That is, when running
a Job on a host consists of a phase to initialize a local compute environment, then running one
or more Tasks that each run the same application for the Job on the host, and finally tearing down
the initialized compute environment when complete.

Some of the reasons that you should consider creating an Adaptor are if you want to:

1. Optimize the runtime of your Job on a compute host by loading the application once and dynamically running
   many units of work with that single application instance before shutting down the application;
2. Programmatically respond to signals that the application provides, such as stopping the application early
   if it prints a message to stdout that indicates that the run may produce undesirable results like watermarks
   due to missing a floating license, or a bad image render due to missing textures;
3. Dynamically select which version of an application to run based on what is available and modify the
   command-line options provided to the application based on which version will be run;
4. Emit [Open Job Description Stdout Messages], or equivalent, to update the batch computing system on the
   status or progress of the running unit of work; and/or
5. Integrate [Open Job Description Path Mapping] information into the application in the format that it is expecting.

[Open Job Description Sessions]: https://github.com/OpenJobDescription/openjd-specifications/wiki/How-Jobs-Are-Run#sessions
[Open Job Description Stdout Messages]: https://github.com/OpenJobDescription/openjd-specifications/wiki/How-Jobs-Are-Run#stdoutstderr-messages
[Open Job Description Path Mapping]: https://github.com/OpenJobDescription/openjd-specifications/wiki/How-Jobs-Are-Run#path-mapping

## Compatibility

This library requires:

1. Python 3.9 or higher; and
2. Linux, MacOS, or Windows operating system.

## Versioning

This package's version follows [Semantic Versioning 2.0](https://semver.org/), but is still considered to be in its 
initial development, thus backwards incompatible versions are denoted by minor version bumps. To help illustrate how
versions will increment during this initial development stage, they are described below:

1. The MAJOR version is currently 0, indicating initial development. 
2. The MINOR version is currently incremented when backwards incompatible changes are introduced to the public API. 
3. The PATCH version is currently incremented when bug fixes or backwards compatible changes are introduced to the public API. 

## Downloading

You can download this package from:
- [PyPI](https://pypi.org/project/openjd-adaptor-runtime/)
- [GitHub releases](https://github.com/OpenJobDescription/openjd-adaptor-runtime-for-python/releases)

### Verifying GitHub Releases

See [VERIFYING_PGP_SIGNATURE](VERIFYING_PGP_SIGNATURE.md) for more information.

## Usage

To create your own Adaptor you create a Python application that uses this package and consists of:

1. A console script entrypoint that passes control flow to an instance of this runtime's **EntryPoint** class;
2. A JSON file for configuration options of your Adaptor; and
3. An Adaptor class derived from either the **CommandAdaptor** or **Adaptor** class.
    - **CommandAdaptor** is ideal for applications where you do not need to initialize the local compute environment by, say,
       preloading your application, and simply need to run a single commandline for each Task that is run on the compute host.
       Please see [CommandAdaptorExample] in this GitHub repository for a simple example.
    - **Adaptor** exposes callbacks for every stage of an Adaptor's lifecycle, and is is suited for Adaptors where you want full control.
       Please see [AdaptorExample] in this GitHub repository for a simple example.

You can also find many more examples within the [AWS Deadline Cloud Organization] on GitHub.

[CommandAdaptorExample]: https://github.com/OpenJobDescription/openjd-adaptor-runtime-for-python/tree/release/test/openjd/adaptor_runtime/integ/CommandAdaptorExample
[AdaptorExample]: https://github.com/OpenJobDescription/openjd-adaptor-runtime-for-python/tree/mainline/test/openjd/adaptor_runtime/integ/AdaptorExample
[AWS Deadline Cloud Organization]: https://github.com/aws-deadline

### Adaptor Lifecycle

All Adaptors undergo a lifecycle consisting of the following stages:

1. **start**: Occurs once during construction and initialization of the Adaptor. This is the stage where
   your Adaptor should perform any expensive initialization actions for the local compute environment; such
   as starting and loading an application in the background for use in later stages of the Adaptor's lifecycle.
    - Runs the `on_start()` method of Adaptors derived from the **Adaptor** base class.
2. **run**: May occur one or more times for a single running Adaptor. This is the stage where your Adaptor is
   performing the work required of a Task that is being run.
    - Run the `on_run()` method of Adaptors derived from the **Adaptor** base class.
    - Run the `on_prerun()` then `get_managed_process()` then `on_postrun()` methods of Adaptors derived from the
     **CommandAdaptor** base class.
3. **stop**: Occurs once as part of shutting down the Adaptor. This stage is the inverse of the **start**
   stage and should undo the actions done in that phase; such as stopping any background processes that are
   still running.
    - Runs the `on_stop()` method of Adaptors derived from the **Adaptor** base class.
4. **cleanup**: A final opportunity to cleanup any remaining processes and data left behind by the Adaptor.
    - Runs the `on_cleanup()` method of Adaptors derived from the **Adaptor** base class.

A running Adaptor can also be canceled by sending the Adaptor process a signal (SIGINT/SIGTERM on posix, or
CTRL-C/CTRL-BREAK on Windows). This will call the `on_cancel()` method of your Adaptor, if one is defined. 
You should ensure that the design of your Adaptor allows this cancelation to interrupt any actions that may
be running, and gracefully exit any running background processes.

### Running an Adaptor

The **EntryPoint** provided by this runtime allows for an Adaptor to be run directly through its
entire lifecycle in a single command, or to be run as a background daemon that lets you drive the lifecycle
of the Adaptor yourself.

#### The `run` Subcommand

The `run` subcommand of an Adaptor will run it through its entire lifecycle (**start**, then **run**, then
**stop**, and finally **cleanup**), and then exit. This is useful for initial development and testing, and
for running Adaptors created from the **CommandAdaptor** base class.

To see this in action install the openjd-adaptor-runtime package into your Python environment, and then
within your local clone of this repository:

```bash
cd test/openjd
python3 -m integ.AdaptorExample run --init-data '{"name": "MyAdaptor"}'  --run-data '{"hello": "world"}'
```

The arguments to the `run` subcommand are:

- **`--init-data`** is a JSON-encoded dictionary either inline or in a given file (`file://<path-to-file>`). This data is
  decoded and automatically stored in the `self.init_data` member of the running Adaptor.
- **`--run-data`** is, similarly, a JSON-encoded dictionary either inline or in a given file (`file://<path-to-file>`).
  This data is passed as the argument to the `on_run()` method of an **Adaptor** or the `get_managed_process()`
  method of a **CommandAdaptor**.

#### The `daemon` Subcommand

With the `daemon` subcommand, you must transition the Adaptor through its lifecycle yourself by running the
subcommands of the `daemon` subcommand in order.

1. Start the Adaptor: Initializes the Adaptor as a background daemon subprocess and leaves it running.
   This runs the `on_start()` method of your **Adaptor**-derived Adaptor if the method is available.
    ```
    python -m integ.AdaptorExample daemon start --connection-file ./AdaptorExampleConnection.json --init-data '{"name": "MyAdaptor"}'
    ```
   - **`--init-data`** is as described in the `run` subcommand, above.
   - **`--connection-file`** provide a path to a JSON file for the Adaptor to create. This file contains information
     on how to connect to the daemon subprocess remains running, and you must provide it to all subsequent runs of the
     Adaptor until you have stopped it.
2. Run the Adaptor: Connects to the daemon subprocess that is running the Adaptor and instructs it to perform its **run**
   lifecycle phase. The command remains connected to the daemon subprocess for the entire duration of this **run** phase,
   and forwards all data logged by the Adaptor to stdout or stderr. This step can be repeated multiple times.
    ```
    python -m integ.AdaptorExample daemon run --connection-file ./AdaptorExampleConnection.json --run-data '{"hello": "world"}'
    ```
   - **`--run-data`** is as described in the `run` subcommand, above.
   - **`--connection-file`** is as described in above.
3. Stop the Adaptor: Connects to the daemon subprocess that is running the Adaptor and instructs it to transition to the
   **stop** then **cleanup** lifecycle phases, and then instructs the daemon subprocess to exit when complete. The command
   remains connected to the daemon subprocess for the entire duration, and forwards all data logged by the Adaptor to stdout
   or stderr.
    ```
    python -m integ.AdaptorExample daemon stop --connection-file ./AdaptorExampleConnection.json
    ```

## Security

We take all security reports seriously. When we receive such reports, we will 
investigate and subsequently address any potential vulnerabilities as quickly 
as possible. If you discover a potential security issue in this project, please 
notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/)
or directly via email to [AWS Security](aws-security@amazon.com). Please do not 
create a public GitHub issue in this project.

## License

This project is licensed under the Apache-2.0 License.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "openjd-adaptor-runtime",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Amazon Web Services",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d8/b2/e8fc7f661c540b7b0a39fefef66bac9880bce1dcc618e64a0ffd7150d176/openjd_adaptor_runtime-0.8.1.tar.gz",
    "platform": null,
    "description": "# Open Job Description - Adaptor Runtime\n\n[![pypi](https://img.shields.io/pypi/v/openjd-adaptor-runtime.svg?style=flat)](https://pypi.python.org/pypi/openjd-adaptor-runtime)\n[![python](https://img.shields.io/pypi/pyversions/openjd-adaptor-runtime.svg?style=flat)](https://pypi.python.org/pypi/openjd-adaptor-runtime)\n[![license](https://img.shields.io/pypi/l/openjd-adaptor-runtime.svg?style=flat)](https://github.com/OpenJobDescription/openjd-adaptor-runtime/blob/mainline/LICENSE)\n\nThis package provides a runtime library for creating a command-line Adaptor to assist with\nintegrating an existing application, such as a rendering application, into batch computing systems\nthat run Jobs in a way that is compatible with [Open Job Description Sessions]. That is, when running\na Job on a host consists of a phase to initialize a local compute environment, then running one\nor more Tasks that each run the same application for the Job on the host, and finally tearing down\nthe initialized compute environment when complete.\n\nSome of the reasons that you should consider creating an Adaptor are if you want to:\n\n1. Optimize the runtime of your Job on a compute host by loading the application once and dynamically running\n   many units of work with that single application instance before shutting down the application;\n2. Programmatically respond to signals that the application provides, such as stopping the application early\n   if it prints a message to stdout that indicates that the run may produce undesirable results like watermarks\n   due to missing a floating license, or a bad image render due to missing textures;\n3. Dynamically select which version of an application to run based on what is available and modify the\n   command-line options provided to the application based on which version will be run;\n4. Emit [Open Job Description Stdout Messages], or equivalent, to update the batch computing system on the\n   status or progress of the running unit of work; and/or\n5. Integrate [Open Job Description Path Mapping] information into the application in the format that it is expecting.\n\n[Open Job Description Sessions]: https://github.com/OpenJobDescription/openjd-specifications/wiki/How-Jobs-Are-Run#sessions\n[Open Job Description Stdout Messages]: https://github.com/OpenJobDescription/openjd-specifications/wiki/How-Jobs-Are-Run#stdoutstderr-messages\n[Open Job Description Path Mapping]: https://github.com/OpenJobDescription/openjd-specifications/wiki/How-Jobs-Are-Run#path-mapping\n\n## Compatibility\n\nThis library requires:\n\n1. Python 3.9 or higher; and\n2. Linux, MacOS, or Windows operating system.\n\n## Versioning\n\nThis package's version follows [Semantic Versioning 2.0](https://semver.org/), but is still considered to be in its \ninitial development, thus backwards incompatible versions are denoted by minor version bumps. To help illustrate how\nversions will increment during this initial development stage, they are described below:\n\n1. The MAJOR version is currently 0, indicating initial development. \n2. The MINOR version is currently incremented when backwards incompatible changes are introduced to the public API. \n3. The PATCH version is currently incremented when bug fixes or backwards compatible changes are introduced to the public API. \n\n## Downloading\n\nYou can download this package from:\n- [PyPI](https://pypi.org/project/openjd-adaptor-runtime/)\n- [GitHub releases](https://github.com/OpenJobDescription/openjd-adaptor-runtime-for-python/releases)\n\n### Verifying GitHub Releases\n\nSee [VERIFYING_PGP_SIGNATURE](VERIFYING_PGP_SIGNATURE.md) for more information.\n\n## Usage\n\nTo create your own Adaptor you create a Python application that uses this package and consists of:\n\n1. A console script entrypoint that passes control flow to an instance of this runtime's **EntryPoint** class;\n2. A JSON file for configuration options of your Adaptor; and\n3. An Adaptor class derived from either the **CommandAdaptor** or **Adaptor** class.\n    - **CommandAdaptor** is ideal for applications where you do not need to initialize the local compute environment by, say,\n       preloading your application, and simply need to run a single commandline for each Task that is run on the compute host.\n       Please see [CommandAdaptorExample] in this GitHub repository for a simple example.\n    - **Adaptor** exposes callbacks for every stage of an Adaptor's lifecycle, and is is suited for Adaptors where you want full control.\n       Please see [AdaptorExample] in this GitHub repository for a simple example.\n\nYou can also find many more examples within the [AWS Deadline Cloud Organization] on GitHub.\n\n[CommandAdaptorExample]: https://github.com/OpenJobDescription/openjd-adaptor-runtime-for-python/tree/release/test/openjd/adaptor_runtime/integ/CommandAdaptorExample\n[AdaptorExample]: https://github.com/OpenJobDescription/openjd-adaptor-runtime-for-python/tree/mainline/test/openjd/adaptor_runtime/integ/AdaptorExample\n[AWS Deadline Cloud Organization]: https://github.com/aws-deadline\n\n### Adaptor Lifecycle\n\nAll Adaptors undergo a lifecycle consisting of the following stages:\n\n1. **start**: Occurs once during construction and initialization of the Adaptor. This is the stage where\n   your Adaptor should perform any expensive initialization actions for the local compute environment; such\n   as starting and loading an application in the background for use in later stages of the Adaptor's lifecycle.\n    - Runs the `on_start()` method of Adaptors derived from the **Adaptor** base class.\n2. **run**: May occur one or more times for a single running Adaptor. This is the stage where your Adaptor is\n   performing the work required of a Task that is being run.\n    - Run the `on_run()` method of Adaptors derived from the **Adaptor** base class.\n    - Run the `on_prerun()` then `get_managed_process()` then `on_postrun()` methods of Adaptors derived from the\n     **CommandAdaptor** base class.\n3. **stop**: Occurs once as part of shutting down the Adaptor. This stage is the inverse of the **start**\n   stage and should undo the actions done in that phase; such as stopping any background processes that are\n   still running.\n    - Runs the `on_stop()` method of Adaptors derived from the **Adaptor** base class.\n4. **cleanup**: A final opportunity to cleanup any remaining processes and data left behind by the Adaptor.\n    - Runs the `on_cleanup()` method of Adaptors derived from the **Adaptor** base class.\n\nA running Adaptor can also be canceled by sending the Adaptor process a signal (SIGINT/SIGTERM on posix, or\nCTRL-C/CTRL-BREAK on Windows). This will call the `on_cancel()` method of your Adaptor, if one is defined. \nYou should ensure that the design of your Adaptor allows this cancelation to interrupt any actions that may\nbe running, and gracefully exit any running background processes.\n\n### Running an Adaptor\n\nThe **EntryPoint** provided by this runtime allows for an Adaptor to be run directly through its\nentire lifecycle in a single command, or to be run as a background daemon that lets you drive the lifecycle\nof the Adaptor yourself.\n\n#### The `run` Subcommand\n\nThe `run` subcommand of an Adaptor will run it through its entire lifecycle (**start**, then **run**, then\n**stop**, and finally **cleanup**), and then exit. This is useful for initial development and testing, and\nfor running Adaptors created from the **CommandAdaptor** base class.\n\nTo see this in action install the openjd-adaptor-runtime package into your Python environment, and then\nwithin your local clone of this repository:\n\n```bash\ncd test/openjd\npython3 -m integ.AdaptorExample run --init-data '{\"name\": \"MyAdaptor\"}'  --run-data '{\"hello\": \"world\"}'\n```\n\nThe arguments to the `run` subcommand are:\n\n- **`--init-data`** is a JSON-encoded dictionary either inline or in a given file (`file://<path-to-file>`). This data is\n  decoded and automatically stored in the `self.init_data` member of the running Adaptor.\n- **`--run-data`** is, similarly, a JSON-encoded dictionary either inline or in a given file (`file://<path-to-file>`).\n  This data is passed as the argument to the `on_run()` method of an **Adaptor** or the `get_managed_process()`\n  method of a **CommandAdaptor**.\n\n#### The `daemon` Subcommand\n\nWith the `daemon` subcommand, you must transition the Adaptor through its lifecycle yourself by running the\nsubcommands of the `daemon` subcommand in order.\n\n1. Start the Adaptor: Initializes the Adaptor as a background daemon subprocess and leaves it running.\n   This runs the `on_start()` method of your **Adaptor**-derived Adaptor if the method is available.\n    ```\n    python -m integ.AdaptorExample daemon start --connection-file ./AdaptorExampleConnection.json --init-data '{\"name\": \"MyAdaptor\"}'\n    ```\n   - **`--init-data`** is as described in the `run` subcommand, above.\n   - **`--connection-file`** provide a path to a JSON file for the Adaptor to create. This file contains information\n     on how to connect to the daemon subprocess remains running, and you must provide it to all subsequent runs of the\n     Adaptor until you have stopped it.\n2. Run the Adaptor: Connects to the daemon subprocess that is running the Adaptor and instructs it to perform its **run**\n   lifecycle phase. The command remains connected to the daemon subprocess for the entire duration of this **run** phase,\n   and forwards all data logged by the Adaptor to stdout or stderr. This step can be repeated multiple times.\n    ```\n    python -m integ.AdaptorExample daemon run --connection-file ./AdaptorExampleConnection.json --run-data '{\"hello\": \"world\"}'\n    ```\n   - **`--run-data`** is as described in the `run` subcommand, above.\n   - **`--connection-file`** is as described in above.\n3. Stop the Adaptor: Connects to the daemon subprocess that is running the Adaptor and instructs it to transition to the\n   **stop** then **cleanup** lifecycle phases, and then instructs the daemon subprocess to exit when complete. The command\n   remains connected to the daemon subprocess for the entire duration, and forwards all data logged by the Adaptor to stdout\n   or stderr.\n    ```\n    python -m integ.AdaptorExample daemon stop --connection-file ./AdaptorExampleConnection.json\n    ```\n\n## Security\n\nWe take all security reports seriously. When we receive such reports, we will \ninvestigate and subsequently address any potential vulnerabilities as quickly \nas possible. If you discover a potential security issue in this project, please \nnotify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/)\nor directly via email to [AWS Security](aws-security@amazon.com). Please do not \ncreate a public GitHub issue in this project.\n\n## License\n\nThis project is licensed under the Apache-2.0 License.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A python library for building adaptors that integrate applications with Open Job Description jobs.",
    "version": "0.8.1",
    "project_urls": {
        "Homepage": "https://github.com/OpenJobDescription/openjd-adaptor-runtime-for-python",
        "Source": "https://github.com/OpenJobDescription/openjd-adaptor-runtime-for-python"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9aec0e778d05104707c723ff1836ed5023eddb5eb8f9d19ab8bd36e02ef7de73",
                "md5": "4e27ac3940ac8890769cfd03338feea7",
                "sha256": "c899293d4eceff0ac0bd02ddcee3f96c79e69ae76175d9cf03f993307c262a81"
            },
            "downloads": -1,
            "filename": "openjd_adaptor_runtime-0.8.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4e27ac3940ac8890769cfd03338feea7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 98705,
            "upload_time": "2024-11-13T21:21:20",
            "upload_time_iso_8601": "2024-11-13T21:21:20.477032Z",
            "url": "https://files.pythonhosted.org/packages/9a/ec/0e778d05104707c723ff1836ed5023eddb5eb8f9d19ab8bd36e02ef7de73/openjd_adaptor_runtime-0.8.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d8b2e8fc7f661c540b7b0a39fefef66bac9880bce1dcc618e64a0ffd7150d176",
                "md5": "659fd8a5ab69e4943af55c611f0d7a74",
                "sha256": "9230002d9d73e5120d211535bb9fff7fe1d9fea0c6e0f301ff0fe731cbd62747"
            },
            "downloads": -1,
            "filename": "openjd_adaptor_runtime-0.8.1.tar.gz",
            "has_sig": false,
            "md5_digest": "659fd8a5ab69e4943af55c611f0d7a74",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 67018,
            "upload_time": "2024-11-13T21:21:22",
            "upload_time_iso_8601": "2024-11-13T21:21:22.426710Z",
            "url": "https://files.pythonhosted.org/packages/d8/b2/e8fc7f661c540b7b0a39fefef66bac9880bce1dcc618e64a0ffd7150d176/openjd_adaptor_runtime-0.8.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-13 21:21:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "OpenJobDescription",
    "github_project": "openjd-adaptor-runtime-for-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "openjd-adaptor-runtime"
}
        
Elapsed time: 1.42212s