dpdispatcher.contexts package#
Contexts.
Submodules#
dpdispatcher.contexts.dp_cloud_server_context module#
Stage files for the legacy Bohrium cloud-service backend.
- class dpdispatcher.contexts.dp_cloud_server_context.BohriumContext(*args: Any, **kwargs: Any)[source]#
Bases:
BaseContextTransfer submissions through Bohrium object storage and cloud APIs.
Methods
bind_submission(submission)Bind a submission and its derived working paths to this context.
block_call(cmd)Run command with arguments.
block_checkcall(cmd[, asynchronously])Run command with arguments.
check_file_exists(fname)Return whether a file exists in the active execution root.
check_finish(proc)Return whether an asynchronous process has finished.
clean()Remove the submission-specific execution directory.
download(submission[, check_exists, ...])Download completed job archives and record their extracted paths.
load_from_dict(context_dict)Create a registered context from a machine configuration mapping.
machine_arginfo()Generate the machine arginfo.
Generate the machine subfields.
read_file(fname)Read text from a file relative to the execution root.
upload(submission)Upload all files required by a submission to the execution root.
write_file(fname, write_str)Write text to a file relative to the execution root.
write_local_file(fname, write_str)Write a backend-local staging file when the context supports it.
check_home_file_exits
read_home_file
upload_job
write_home_file
- bind_submission(submission: Submission) None[source]#
Bind a submission and its derived working paths to this context.
- block_call(cmd: str) NoReturn[source]#
Run command with arguments. Wait for command to complete.
- Parameters:
- cmdstr
The command to run.
- Returns:
- exit_status
exit code
- stdin
standard inout
- stdout
standard output
- stderr
standard error
- check_file_exists(fname: str) bool[source]#
Return whether a file exists in the active execution root.
- download(submission: Submission, check_exists: bool = False, mark_failure: bool = True, back_error: bool = False) bool[source]#
Download completed job archives and record their extracted paths.
- classmethod load_from_dict(context_dict: dict[str, Any]) BohriumContext[source]#
Create a registered context from a machine configuration mapping.
- classmethod machine_subfields() list[Argument][source]#
Generate the machine subfields.
- Returns:
- list[Argument]
machine subfields
- upload(submission: Submission) None[source]#
Upload all files required by a submission to the execution root.
- dpdispatcher.contexts.dp_cloud_server_context.DpCloudServerContext#
alias of
BohriumContext
- dpdispatcher.contexts.dp_cloud_server_context.LebesgueContext#
alias of
BohriumContext
dpdispatcher.contexts.hdfs_context module#
Stage DistributedShell submission data through HDFS archives.
- class dpdispatcher.contexts.hdfs_context.HDFSContext(*args: Any, **kwargs: Any)[source]#
Bases:
BaseContextTransfer submission inputs and outputs between local storage and HDFS.
Methods
bind_submission(submission)Bind a submission and its derived working paths to this context.
block_call(cmd)Run command with arguments.
block_checkcall(cmd[, asynchronously])Run command with arguments.
check_file_exists(fname)Check whether the given file exists, often used in checking whether the belonging job has finished.
check_finish(proc)Return whether an asynchronous process has finished.
clean()Remove the submission-specific execution directory.
download(submission[, check_exists, ...])Download backward files from HDFS root dir.
load_from_dict(context_dict)Create a registered context from a machine configuration mapping.
machine_arginfo()Generate the machine arginfo.
machine_subfields()Generate the machine subfields.
migrate_recovery_root(old_remote_root, ...)Move a recovered submission tree through the HDFS API.
read_file(fname)Read text from a file relative to the execution root.
rollback_recovery_root(current_remote_root, ...)Reverse a recovery migration, tolerating an already-finished rollback.
upload(submission[, dereference])Upload forward files and forward command files to HDFS root dir.
write_file(fname, write_str)Write text to a file relative to the execution root.
write_local_file(fname, write_str)Write a backend-local staging file when the context supports it.
get_job_root
- bind_submission(submission: Submission) None[source]#
Bind a submission and its derived working paths to this context.
- block_call(cmd: str) NoReturn[source]#
Run command with arguments. Wait for command to complete.
- Parameters:
- cmdstr
The command to run.
- Returns:
- exit_status
exit code
- stdin
standard inout
- stdout
standard output
- stderr
standard error
- check_file_exists(fname: str) bool[source]#
Check whether the given file exists, often used in checking whether the belonging job has finished.
- Parameters:
- fnamestring
file name to be checked
- Returns:
- status: boolean
- download(submission: Submission, check_exists: bool = False, mark_failure: bool = True, back_error: bool = False) None[source]#
Download backward files from HDFS root dir.
- Parameters:
- submissionSubmission class instance
represents a collection of tasks, such as backward file names
- check_existsbool
whether to check if the file exists
- mark_failurebool
whether to mark the task as failed if the file does not exist
- back_errorbool
whether to download error files
- Returns:
- none
- classmethod load_from_dict(context_dict: dict[str, Any]) HDFSContext[source]#
Create a registered context from a machine configuration mapping.
- migrate_recovery_root(old_remote_root: str, new_remote_root: str, *, force: bool = False) bool[source]#
Move a recovered submission tree through the HDFS API.
Resource-only resumes must preserve completion tags stored under the previous hash. Local filesystem operations cannot inspect or rename an HDFS URI, so use backend existence checks and an atomic HDFS move. Existing new-hash state wins to keep repeated recovery idempotent.
- Parameters:
- forcebool, default=False
Treat an existing destination with no source as an already-completed operation and report success. Recovery passes this only while reversing a move, so a concurrent rollback is considered successful instead of being mistaken for a failed rollback.
- Returns:
- bool
Whether this call moved (or, for a forced rollback, confirmed) an existing source root. Recovery uses the signal to roll the move back if subsequent rebinding fails.
- rollback_recovery_root(current_remote_root: str, previous_remote_root: str) bool[source]#
Reverse a recovery migration, tolerating an already-finished rollback.
This dedicated hook keeps the
forcedetail private to HDFS while allowing older third-party contexts that implement only the original two-argument migration hook to remain usable bySubmission.
- upload(submission: Submission, dereference: bool = True) None[source]#
Upload forward files and forward command files to HDFS root dir.
- Parameters:
- submissionSubmission class instance
represents a collection of tasks, such as forward file names
- dereferencebool
whether to dereference symbolic links
- Returns:
- none
dpdispatcher.contexts.lazy_local_context module#
Execute jobs directly inside their existing local working directory.
- class dpdispatcher.contexts.lazy_local_context.LazyLocalContext(*args: Any, **kwargs: Any)[source]#
Bases:
BaseContextRun jobs in the local server and local directory.
- Parameters:
- local_rootstr
The local directory to store the jobs.
- remote_rootstr, optional
The argument takes no effect.
- remote_profiledict, optional
The remote profile. The default is {}.
- *args
The arguments.
- **kwargs
The keyword arguments.
Methods
bind_submission(submission)Bind a submission and its derived working paths to this context.
block_call(cmd)Run command with arguments.
block_checkcall(cmd[, asynchronously])Run command with arguments.
check_file_exists(fname)Return whether a file exists in the active execution root.
check_finish(proc)Return whether an asynchronous process has finished.
clean()Remove the submission-specific execution directory.
download(submission[, check_exists, ...])Download declared result files from the execution root.
load_from_dict(context_dict)Create a registered context from a machine configuration mapping.
machine_arginfo()Generate the machine arginfo.
machine_subfields()Generate the machine subfields.
migrate_recovery_root(old_remote_root, ...)Keep the shared work-base directory in place during recovery.
read_file(fname)Read text from a file relative to the execution root.
upload(submission[, dereference])Upload all files required by a submission to the execution root.
write_file(fname, write_str)Write text to a file relative to the execution root.
write_local_file(fname, write_str)Write a backend-local staging file when the context supports it.
call
get_job_root
get_return
- bind_submission(submission: Submission) None[source]#
Bind a submission and its derived working paths to this context.
- block_call(cmd: str) tuple[int, None, SPRetObj, SPRetObj][source]#
Run command with arguments. Wait for command to complete.
- Parameters:
- cmdstr
The command to run.
- Returns:
- exit_status
exit code
- stdin
standard inout
- stdout
standard output
- stderr
standard error
- check_file_exists(fname: str) bool[source]#
Return whether a file exists in the active execution root.
- download(submission: Submission, check_exists: bool = False, mark_failure: bool = True, back_error: bool = False) None[source]#
Download declared result files from the execution root.
- classmethod load_from_dict(context_dict: dict[str, Any]) LazyLocalContext[source]#
Create a registered context from a machine configuration mapping.
- migrate_recovery_root(old_remote_root: str, new_remote_root: str, *, force: bool = False) bool[source]#
Keep the shared work-base directory in place during recovery.
LazyLocalContext deliberately reuses one directory for every submission hash, so moving it would make the subsequent bind point at a path that this backend never uses.
- Returns:
- bool
Always
Falsebecause the shared work directory is not moved.
- upload(submission: Submission, dereference: bool = True) None[source]#
Upload all files required by a submission to the execution root.
dpdispatcher.contexts.local_context module#
Execute jobs locally while staging them in a separate directory.
- class dpdispatcher.contexts.local_context.LocalContext(*args: Any, **kwargs: Any)[source]#
Bases:
BaseContextRun jobs in the local server and remote directory.
- Parameters:
- local_rootstr
The local directory to store the jobs.
- remote_rootstr
The remote directory to store the jobs.
- remote_profiledict, optional
The remote profile. The default is {}.
- *args
The arguments.
- **kwargs
The keyword arguments.
Methods
bind_submission(submission)Bind a submission and its derived working paths to this context.
block_call(cmd)Run command with arguments.
block_checkcall(cmd[, asynchronously])Run command with arguments.
check_file_exists(fname)Return whether a file exists in the active execution root.
check_finish(proc)Return whether an asynchronous process has finished.
clean()Remove the submission-specific execution directory.
download(submission[, check_exists, ...])Download requested artifacts through a manifest and one copier.
load_from_dict(context_dict)Create a registered context from a machine configuration mapping.
machine_arginfo()Generate the machine arginfo.
Generate the machine subfields.
read_file(fname)Read text from a file relative to the execution root.
upload(submission)Stage all forward files through one validated transfer manifest.
write_file(fname, write_str)Write text to a file relative to the execution root.
write_local_file(fname, write_str)Write a backend-local staging file when the context supports it.
call
get_job_root
get_return
- bind_submission(submission: Submission) None[source]#
Bind a submission and its derived working paths to this context.
- block_call(cmd: str) tuple[int, None, SPRetObj, SPRetObj][source]#
Run command with arguments. Wait for command to complete.
- Parameters:
- cmdstr
The command to run.
- Returns:
- exit_status
exit code
- stdin
standard inout
- stdout
standard output
- stderr
standard error
- check_file_exists(fname: str) bool[source]#
Return whether a file exists in the active execution root.
- download(submission: Submission, check_exists: bool = False, mark_failure: bool = True, back_error: bool = False) None[source]#
Download requested artifacts through a manifest and one copier.
- classmethod load_from_dict(context_dict: dict[str, Any]) LocalContext[source]#
Create a registered context from a machine configuration mapping.
- classmethod machine_subfields() list[Argument][source]#
Generate the machine subfields.
- Returns:
- list[Argument]
machine subfields
- upload(submission: Submission) None[source]#
Stage all forward files through one validated transfer manifest.
dpdispatcher.contexts.openapi_context module#
Stage submissions for Bohrium through its SDK-based OpenAPI.
- class dpdispatcher.contexts.openapi_context.OpenAPIContext(*args: Any, **kwargs: Any)[source]#
Bases:
BaseContextTransfer files with Bohrium object storage authenticated by access key.
Methods
bind_submission(submission)Bind a submission and its derived working paths to this context.
block_call(cmd)Run command with arguments.
block_checkcall(cmd[, asynchronously])Run command with arguments.
check_file_exists(fname)Return whether a file exists in the active execution root.
check_finish(proc)Return whether an asynchronous process has finished.
clean()Remove the submission-specific execution directory.
download(submission[, check_exists, ...])Download completed Bohrium archives and record extracted paths.
load_from_dict(context_dict)Create a registered context from a machine configuration mapping.
machine_arginfo()Generate the machine arginfo.
machine_subfields()Generate the machine subfields.
read_file(fname)Read text from a file relative to the execution root.
upload(submission)Upload all files required by a submission to the execution root.
write_file(fname, write_str)Write text to a file relative to the execution root.
write_local_file(fname, write_str)Write a backend-local staging file when the context supports it.
check_home_file_exits
read_home_file
upload_job
write_home_file
- bind_submission(submission: Submission) None[source]#
Bind a submission and its derived working paths to this context.
- block_call(cmd: str) NoReturn[source]#
Run command with arguments. Wait for command to complete.
- Parameters:
- cmdstr
The command to run.
- Returns:
- exit_status
exit code
- stdin
standard inout
- stdout
standard output
- stderr
standard error
- check_file_exists(fname: str) bool[source]#
Return whether a file exists in the active execution root.
- download(submission: Submission, check_exists: bool = False, mark_failure: bool = True, back_error: bool = False) bool[source]#
Download completed Bohrium archives and record extracted paths.
- classmethod load_from_dict(context_dict: dict[str, Any]) OpenAPIContext[source]#
Create a registered context from a machine configuration mapping.
- upload(submission: Submission) None[source]#
Upload all files required by a submission to the execution root.
dpdispatcher.contexts.ssh_context module#
Provide SSH command execution and rsync/SFTP file staging.
- class dpdispatcher.contexts.ssh_context.SSHContext(*args: Any, **kwargs: Any)[source]#
Bases:
BaseContextRun submissions on a remote host reached through an SSH session.
- Attributes:
- sftp
- ssh
Methods
bind_submission(submission)Bind a submission and its derived working paths to this context.
block_call(cmd)Run command with arguments.
block_checkcall(cmd[, asynchronously])Run command with arguments.
check_file_exists(fname)Return whether a file exists in the active execution root.
check_finish(proc)Return whether an asynchronous process has finished.
clean()Remove the submission-specific execution directory.
download(submission[, check_exists, ...])Download selected remote files using one SFTP-backed manifest.
load_from_dict(context_dict)Create a registered context from a machine configuration mapping.
machine_arginfo()Generate the machine arginfo.
Generate the machine subfields.
read_file(fname)Read text from a file relative to the execution root.
upload(submission[, dereference])Upload all files required by a submission to the execution root.
write_file(fname, write_str)Write text to a file relative to the execution root.
write_local_file(fname, write_str)Write a backend-local staging file when the context supports it.
call
close
get_job_root
get_return
list_remote_dir
- bind_submission(submission: Submission) None[source]#
Bind a submission and its derived working paths to this context.
- block_call(cmd: str) tuple[int, Any, Any, Any][source]#
Run command with arguments. Wait for command to complete.
- Parameters:
- cmdstr
The command to run.
- Returns:
- exit_status
exit code
- stdin
standard inout
- stdout
standard output
- stderr
standard error
- check_file_exists(fname: str) bool[source]#
Return whether a file exists in the active execution root.
- check_finish(proc: dict[str, Any]) bool[source]#
Return whether an asynchronous process has finished.
- download(submission: Submission, check_exists: bool = False, mark_failure: bool = True, back_error: bool = False) None[source]#
Download selected remote files using one SFTP-backed manifest.
Remote wildcard expansion is performed against a single recursive SFTP index; the controller’s local
globimplementation must never be applied to paths that only exist on the remote host.
- list_remote_dir(sftp: SFTPClient, remote_dir: str, ref_remote_root: str, result_list: list[str]) None[source]#
- classmethod load_from_dict(context_dict: dict[str, Any]) SSHContext[source]#
Create a registered context from a machine configuration mapping.
- classmethod machine_subfields() list[Argument][source]#
Generate the machine subfields.
- Returns:
- list[Argument]
machine subfields
- property sftp: SFTPClient#
- property ssh: SSHClient#
- upload(submission: Submission, dereference: bool = True) None[source]#
Upload all files required by a submission to the execution root.
- class dpdispatcher.contexts.ssh_context.SSHSession(hostname: str, username: str, password: str | None = None, port: int = 22, key_filename: str | None = None, passphrase: str | None = None, timeout: int = 10, totp_secret: str | None = None, tar_compress: bool = True, look_for_keys: bool = True, execute_command: str | None = None, proxy_command: str | None = None, archive_chunk_size: int = 0)[source]#
Bases:
objectManage a resilient Paramiko SSH connection and file-transfer helpers.
- Attributes:
- remote
- rsync_available
sftpReturns sftp.
Methods
inter_handler(title, instructions, prompt_list)inter_handler: the callback for paramiko.transport.auth_interactive.
arginfo
close
ensure_alive
exec_command
get
get_ssh_client
put
- inter_handler(title: str, instructions: str, prompt_list: list[tuple[str, bool]]) list[str][source]#
inter_handler: the callback for paramiko.transport.auth_interactive.
The prototype for this function is defined by Paramiko, so all of the arguments need to be there, even though we don’t use ‘title’ or ‘instructions’.
The function is expected to return a tuple of data containing the responses to the provided prompts. Experimental results suggests that there will be one call of this function per prompt, but the mechanism allows for multiple prompts to be sent at once, so it’s best to assume that that can happen.
Since tuples can’t really be built on the fly, the responses are collected in a list which is then converted to a tuple when it’s time to return a value.
Experiments suggest that the username prompt never happens. This makes sense, but the Username prompt is included here just in case.
- property sftp: SFTPClient#
Returns sftp. Open a new one if not existing.