Name | snakemake-interface-executor-plugins JSON |
Version |
9.3.2
JSON |
| download |
home_page | None |
Summary | This package provides a stable interface for interactions between Snakemake and its executor plugins. |
upload_time | 2024-10-06 11:58:25 |
maintainer | None |
docs_url | None |
author | Johannes Köster |
requires_python | <4.0,>=3.11 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Stable interfaces and functionality for Snakemake executor plugins
This package provides a stable interface for interactions between Snakemake and its executor plugins (WIP).
Plugins should implement the following skeleton to comply with this interface.
It is recommended to use Snakemake's poetry plugin to set up this skeleton (and automated testing) within a python package, see https://github.com/snakemake/poetry-snakemake-plugin.
```python
from dataclasses import dataclass, field
from typing import List, Generator, Optional
from snakemake_interface_executor_plugins.executors.base import SubmittedJobInfo
from snakemake_interface_executor_plugins.executors.remote import RemoteExecutor
from snakemake_interface_executor_plugins.settings import (
ExecutorSettingsBase, CommonSettings
)
from snakemake_interface_executor_plugins.workflow import WorkflowExecutorInterface
from snakemake_interface_executor_plugins.logging import LoggerExecutorInterface
from snakemake_interface_executor_plugins.jobs import (
JobExecutorInterface,
)
# Optional:
# Define additional settings for your executor.
# They will occur in the Snakemake CLI as --<executor-name>-<param-name>
# Omit this class if you don't need any.
# Make sure that all defined fields are Optional and specify a default value
# of None or anything else that makes sense in your case.
@dataclass
class ExecutorSettings(ExecutorSettingsBase):
myparam: Optional[int] = field(
default=None,
metadata={
"help": "Some help text",
# Optionally request that setting is also available for specification
# via an environment variable. The variable will be named automatically as
# SNAKEMAKE_<executor-name>_<param-name>, all upper case.
# This mechanism should only be used for passwords and usernames.
# For other items, we rather recommend to let people use a profile
# for setting defaults
# (https://snakemake.readthedocs.io/en/stable/executing/cli.html#profiles).
"env_var": False,
# Optionally specify a function that parses the value given by the user.
# This is useful to create complex types from the user input.
"parse_func": ...,
# If a parse_func is specified, you also have to specify an unparse_func
# that converts the parsed value back to a string.
"unparse_func": ...,
# Optionally specify that setting is required when the executor is in use.
"required": True,
# Optionally specify multiple args with "nargs": True
},
)
# Required:
# Specify common settings shared by various executors.
common_settings = CommonSettings(
# define whether your executor plugin executes locally
# or remotely. In virtually all cases, it will be remote execution
# (cluster, cloud, etc.). Only Snakemake's standard execution
# plugins (snakemake-executor-plugin-dryrun, snakemake-executor-plugin-local)
# are expected to specify False here.
non_local_exec=True,
# Whether the executor implies to not have a shared file system
implies_no_shared_fs=True,
# whether to deploy workflow sources to default storage provider before execution
job_deploy_sources=True,
# whether arguments for setting the storage provider shall be passed to jobs
pass_default_storage_provider_args=True,
# whether arguments for setting default resources shall be passed to jobs
pass_default_resources_args=True,
# whether environment variables shall be passed to jobs (if False, use
# self.envvars() to obtain a dict of environment variables and their values
# and pass them e.g. as secrets to the execution backend)
pass_envvar_declarations_to_cmd=True,
# whether the default storage provider shall be deployed before the job is run on
# the remote node. Usually set to True if the executor does not assume a shared fs
auto_deploy_default_storage_provider=True,
# specify initial amount of seconds to sleep before checking for job status
init_seconds_before_status_checks=0,
)
# Required:
# Implementation of your executor
class Executor(RemoteExecutor):
def __post_init__(self):
# access workflow
self.workflow
# access executor specific settings
self.workflow.executor_settings
# IMPORTANT: in your plugin, only access methods and properties of
# Snakemake objects (like Workflow, Persistence, etc.) that are
# defined in the interfaces found in the
# snakemake-interface-executor-plugins and the
# snakemake-interface-common package.
# Other parts of those objects are NOT guaranteed to remain
# stable across new releases.
# To ensure that the used interfaces are not changing, you should
# depend on these packages as >=a.b.c,<d with d=a+1 (i.e. pin the
# dependency on this package to be at least the version at time
# of development and less than the next major version which would
# introduce breaking changes).
# In case of errors outside of jobs, please raise a WorkflowError
def run_job(self, job: JobExecutorInterface):
# Implement here how to run a job.
# You can access the job's resources, etc.
# via the job object.
# After submitting the job, you have to call
# self.report_job_submission(job_info).
# with job_info being of type
# snakemake_interface_executor_plugins.executors.base.SubmittedJobInfo.
# If required, make sure to pass the job's id to the job_info object, as keyword
# argument 'external_job_id'.
...
async def check_active_jobs(
self, active_jobs: List[SubmittedJobInfo]
) -> Generator[SubmittedJobInfo, None, None]:
# Check the status of active jobs.
# You have to iterate over the given list active_jobs.
# If you provided it above, each will have its external_jobid set according
# to the information you provided at submission time.
# For jobs that have finished successfully, you have to call
# self.report_job_success(active_job).
# For jobs that have errored, you have to call
# self.report_job_error(active_job).
# This will also take care of providing a proper error message.
# Usually there is no need to perform additional logging here.
# Jobs that are still running have to be yielded.
#
# For queries to the remote middleware, please use
# self.status_rate_limiter like this:
#
# async with self.status_rate_limiter:
# # query remote middleware here
#
# To modify the time until the next call of this method,
# you can set self.next_sleep_seconds here.
...
def cancel_jobs(self, active_jobs: List[SubmittedJobInfo]):
# Cancel all active jobs.
# This method is called when Snakemake is interrupted.
...
```
Raw data
{
"_id": null,
"home_page": null,
"name": "snakemake-interface-executor-plugins",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": null,
"author": "Johannes K\u00f6ster",
"author_email": "johannes.koester@uni-due.de",
"download_url": "https://files.pythonhosted.org/packages/6f/77/f3e7a7abff8f15bd50f168eef1e3153167a681bfd51a454a3adb0918cb8d/snakemake_interface_executor_plugins-9.3.2.tar.gz",
"platform": null,
"description": "# Stable interfaces and functionality for Snakemake executor plugins\n\nThis package provides a stable interface for interactions between Snakemake and its executor plugins (WIP).\n\nPlugins should implement the following skeleton to comply with this interface.\nIt is recommended to use Snakemake's poetry plugin to set up this skeleton (and automated testing) within a python package, see https://github.com/snakemake/poetry-snakemake-plugin.\n\n```python\nfrom dataclasses import dataclass, field\nfrom typing import List, Generator, Optional\nfrom snakemake_interface_executor_plugins.executors.base import SubmittedJobInfo\nfrom snakemake_interface_executor_plugins.executors.remote import RemoteExecutor\nfrom snakemake_interface_executor_plugins.settings import (\n ExecutorSettingsBase, CommonSettings\n)\nfrom snakemake_interface_executor_plugins.workflow import WorkflowExecutorInterface\nfrom snakemake_interface_executor_plugins.logging import LoggerExecutorInterface\nfrom snakemake_interface_executor_plugins.jobs import (\n JobExecutorInterface,\n)\n\n# Optional:\n# Define additional settings for your executor.\n# They will occur in the Snakemake CLI as --<executor-name>-<param-name>\n# Omit this class if you don't need any.\n# Make sure that all defined fields are Optional and specify a default value\n# of None or anything else that makes sense in your case.\n@dataclass\nclass ExecutorSettings(ExecutorSettingsBase):\n myparam: Optional[int] = field(\n default=None,\n metadata={\n \"help\": \"Some help text\",\n # Optionally request that setting is also available for specification\n # via an environment variable. The variable will be named automatically as\n # SNAKEMAKE_<executor-name>_<param-name>, all upper case.\n # This mechanism should only be used for passwords and usernames.\n # For other items, we rather recommend to let people use a profile\n # for setting defaults\n # (https://snakemake.readthedocs.io/en/stable/executing/cli.html#profiles).\n \"env_var\": False,\n # Optionally specify a function that parses the value given by the user.\n # This is useful to create complex types from the user input.\n \"parse_func\": ...,\n # If a parse_func is specified, you also have to specify an unparse_func\n # that converts the parsed value back to a string.\n \"unparse_func\": ...,\n # Optionally specify that setting is required when the executor is in use.\n \"required\": True,\n # Optionally specify multiple args with \"nargs\": True\n },\n )\n\n\n# Required:\n# Specify common settings shared by various executors.\ncommon_settings = CommonSettings(\n # define whether your executor plugin executes locally\n # or remotely. In virtually all cases, it will be remote execution\n # (cluster, cloud, etc.). Only Snakemake's standard execution \n # plugins (snakemake-executor-plugin-dryrun, snakemake-executor-plugin-local)\n # are expected to specify False here.\n non_local_exec=True,\n # Whether the executor implies to not have a shared file system\n implies_no_shared_fs=True,\n # whether to deploy workflow sources to default storage provider before execution\n job_deploy_sources=True,\n # whether arguments for setting the storage provider shall be passed to jobs\n pass_default_storage_provider_args=True,\n # whether arguments for setting default resources shall be passed to jobs\n pass_default_resources_args=True,\n # whether environment variables shall be passed to jobs (if False, use \n # self.envvars() to obtain a dict of environment variables and their values\n # and pass them e.g. as secrets to the execution backend)\n pass_envvar_declarations_to_cmd=True,\n # whether the default storage provider shall be deployed before the job is run on \n # the remote node. Usually set to True if the executor does not assume a shared fs\n auto_deploy_default_storage_provider=True,\n # specify initial amount of seconds to sleep before checking for job status\n init_seconds_before_status_checks=0,\n)\n\n\n# Required:\n# Implementation of your executor\nclass Executor(RemoteExecutor):\n def __post_init__(self):\n # access workflow\n self.workflow\n # access executor specific settings\n self.workflow.executor_settings\n\n # IMPORTANT: in your plugin, only access methods and properties of\n # Snakemake objects (like Workflow, Persistence, etc.) that are\n # defined in the interfaces found in the\n # snakemake-interface-executor-plugins and the\n # snakemake-interface-common package.\n # Other parts of those objects are NOT guaranteed to remain\n # stable across new releases.\n\n # To ensure that the used interfaces are not changing, you should\n # depend on these packages as >=a.b.c,<d with d=a+1 (i.e. pin the\n # dependency on this package to be at least the version at time\n # of development and less than the next major version which would\n # introduce breaking changes).\n\n # In case of errors outside of jobs, please raise a WorkflowError\n\n def run_job(self, job: JobExecutorInterface):\n # Implement here how to run a job.\n # You can access the job's resources, etc.\n # via the job object.\n # After submitting the job, you have to call\n # self.report_job_submission(job_info).\n # with job_info being of type\n # snakemake_interface_executor_plugins.executors.base.SubmittedJobInfo.\n # If required, make sure to pass the job's id to the job_info object, as keyword\n # argument 'external_job_id'.\n\n ...\n\n async def check_active_jobs(\n self, active_jobs: List[SubmittedJobInfo]\n ) -> Generator[SubmittedJobInfo, None, None]:\n # Check the status of active jobs.\n\n # You have to iterate over the given list active_jobs.\n # If you provided it above, each will have its external_jobid set according\n # to the information you provided at submission time.\n # For jobs that have finished successfully, you have to call\n # self.report_job_success(active_job).\n # For jobs that have errored, you have to call\n # self.report_job_error(active_job).\n # This will also take care of providing a proper error message.\n # Usually there is no need to perform additional logging here.\n # Jobs that are still running have to be yielded.\n #\n # For queries to the remote middleware, please use\n # self.status_rate_limiter like this:\n #\n # async with self.status_rate_limiter:\n # # query remote middleware here\n #\n # To modify the time until the next call of this method,\n # you can set self.next_sleep_seconds here.\n ...\n\n def cancel_jobs(self, active_jobs: List[SubmittedJobInfo]):\n # Cancel all active jobs.\n # This method is called when Snakemake is interrupted.\n ...\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "This package provides a stable interface for interactions between Snakemake and its executor plugins.",
"version": "9.3.2",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7c840b7602c54d97b2cd3b40fc4c80633d42afcf69e441d9f25c928376051be8",
"md5": "956b68fd22964b6dd6d887c726a94186",
"sha256": "9c52c4b0f74b9056ebbb1b6229459281fef002b678baac00aee3b3ef36e92ba5"
},
"downloads": -1,
"filename": "snakemake_interface_executor_plugins-9.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "956b68fd22964b6dd6d887c726a94186",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 22389,
"upload_time": "2024-10-06T11:58:23",
"upload_time_iso_8601": "2024-10-06T11:58:23.642655Z",
"url": "https://files.pythonhosted.org/packages/7c/84/0b7602c54d97b2cd3b40fc4c80633d42afcf69e441d9f25c928376051be8/snakemake_interface_executor_plugins-9.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6f77f3e7a7abff8f15bd50f168eef1e3153167a681bfd51a454a3adb0918cb8d",
"md5": "30dcb5b835add189557bf2c143ff4236",
"sha256": "19c50dc82989ff25d10386cfb3c99da9d2dc980d95ecd30bbb431374dcd390b3"
},
"downloads": -1,
"filename": "snakemake_interface_executor_plugins-9.3.2.tar.gz",
"has_sig": false,
"md5_digest": "30dcb5b835add189557bf2c143ff4236",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 16714,
"upload_time": "2024-10-06T11:58:25",
"upload_time_iso_8601": "2024-10-06T11:58:25.065896Z",
"url": "https://files.pythonhosted.org/packages/6f/77/f3e7a7abff8f15bd50f168eef1e3153167a681bfd51a454a3adb0918cb8d/snakemake_interface_executor_plugins-9.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-06 11:58:25",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "snakemake-interface-executor-plugins"
}