pyslk.jobs package

Contents

pyslk.jobs package#

Submodules#

pyslk.jobs.basic module#

pyslk.jobs.basic.get_job_status(job_id: int) StatusJob | None#

Check the status of a job

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

job status; None, if job_id does not exist

Return type:

pyslk.StatusJob or None

pyslk.jobs.basic.is_job_finished(job_id: int) bool | None#

Check the status of a tape

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

True if job with job_id is finished; else False

Return type:

bool or None

pyslk.jobs.basic.is_job_processing(job_id: int) bool | None#

Check the status of a tape

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

True if job with job_id is currently being processed; else False

Return type:

bool or None

pyslk.jobs.basic.is_job_queued(job_id: int) bool | None#

Check the status of a tape

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

True if job with job_id is queued; else False

Return type:

bool or None

pyslk.jobs.basic.is_job_successful(job_id: int) bool | None#

Check the status of a tape

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

True if job with job_id is finished and was successful; else False

Return type:

bool or None

pyslk.jobs.basic.job_exists(job_id: int) bool#

Check if job exists

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

True if job exists; False otherwise

Return type:

bool

pyslk.jobs.basic.job_queue() dict#

Prints status of the queue of tape read jobs

Returns:

information on the recall job queue (number of queued and processing jobs and some more information)

Return type:

dict

pyslk.jobs.submitted_jobs module#

class pyslk.jobs.submitted_jobs.SubmittedJobs(*, submitted_jobs_raw_output: str | None = None, resources: str | Path | list[str] | list[pathlib.Path] | None = None, resource_ids: int | str | list[int] | list[str] | None = None, search_id: int | str | None = None, search_query: str | None = None, json_input_file: str | Path | None = None, recursive: bool = False, resume_on_page: int = 1, results_per_page: int = -1, end_on_page: int = -1, save_mode: bool = False)#

Bases: object

are_completed_details() dict[int, bool]#
are_completed_short() bool#
are_finished_details() dict[int, bool]#
are_finished_short() bool#
are_successful_details() dict[int, bool]#
are_successful_short() bool#
static extract_job_ids(jobs: list[dict]) list[int]#
finished_successfully() bool#
get_job_ids() list[int]#
get_job_information(job_id: int) dict | None#
get_restart_information() dict#
get_search_id() int#
get_search_query() str | None#
get_source() Optional[str, Path, list[int]]#
had_timeout() bool#
has_restart_information() bool#
merge(other: SubmittedJobs)#
missing_restart_information() list[str]#

check whether fields are missing in the available restart information

this json should have been returned by ‘pyslk.submit_verify_jobs_raw’ “restart_information”: {

“search_id”: 613746, “start_page”: 1, “save_mode”: false, “verbose”: false

}

needs_restart() bool#
optional_keys = ['search_query', 'n_max_search_results', 'n_max_verify_jobs', 'n_verify_jobs', 'restart_information']#
required_keys = ['jobs', 'search_id', 'source', 'submitted_all_jobs', 'timeout']#
required_restart_keys = ['search_id', 'start_page', 'save_mode', 'verbose']#
submit(force_save_mode: bool = False)#

submit jobs; fresh start of all jobs and resume interrupted submission

Parameters:

force_save_mode (bool) – force to submit jobs in save mode; forcing non-save mode is not possible by this switch

Returns:

True if all jobs were submitted successfully

Return type:

bool

pyslk.jobs.verify module#

pyslk.jobs.verify.get_bad_files_verify_job(jobs: int | list[int] | set[int] | SubmittedJobs) dict[str, list[pathlib.Path]]#

Get results of one or more verify jobs

Parameters:

jobs (int or list[int] or set[int] or SubmittedJobs) – submitted jobs (job id, list of job ids or SubmittedJobs object)

Returns:

results of the verify job

Return type:

dict[str, list[Path]]

pyslk.jobs.verify.get_checked_resources_verify_job(jobs: int | list[int] | SubmittedJobs, force_resource_path: bool = False) list[Union[int, pathlib.Path]]#

Get results of one or more verify jobs

TODO: doc update

Parameters:
  • jobs (int or list[int] or SubmittedJobs) – submitted jobs (job id, list of job ids or SubmittedJobs object)

  • force_resource_path (bool) – force resource path to be returned; otherwise, resource ids will be returned (except if a namespace was the target of the verify job which is limited to admins)

Returns:

results of the verify job

Return type:

`list[Union[int, Path]]

pyslk.jobs.verify.get_result_verify_job(job_id: int, return_no_source: bool = False) dict[str, dict]#

Get results of one or more verify jobs

Parameters:
  • job_id (int) – job id

  • return_no_source (bool) – return the result of the verify job but do not contain a list of checked files

Returns:

results of the verify job and its header

Return type:

dict[str, dict]

pyslk.jobs.verify.submit_verify_job(resources: str | Path | list[str] | list[pathlib.Path] | None = None, resource_ids: int | str | list[int] | list[str] | None = None, search_id: int | str | None = None, search_query: str | None = None, json_input_file: str | Path | None = None, recursive: bool = False, resume_on_page: int = 1, end_on_page: int = -1, save_mode: bool = False) SubmittedJobs#

Submit a verify job

Parameters:
  • resources (str or Path or list[str] or list[Path] or None) – provide a list of resources over which the verify job should be run

  • resource_ids (str or int or list[str] or list[int] or None) – provide a list of ids of resources over which the verify job should be run

  • search_id (str or int or None) – provide a search id pointing to files over which the verify job should be run

  • search_query (str or None) – provide a search query to select files over which the verify job should be run

  • json_input_file (str or Path or None) – read a JSON file which contains payload of the verify job (admin users only)

  • recursive (bool) – iterate namespaces recursively

  • resume_on_page (int) – resume the command and start with search result page resume_on_page; internally, 1000 search results are on one ‘page’ and fetched by one request; you do not necessarily have read permissions for all of these files

  • end_on_page (int) – end with search result page end_on_page; internally, 1000 search results are on one ‘page’ and fetched by one request; you do not necessarily have read permissions for all of these files

  • save_mode (bool) – save mode suggested to be used in times of many timeouts; please do not regularly use this parameter; start one verify job per page of search results instead of one verify job for 50 pages of search results

Returns:

submitted jobs and, if command failed due to timeout, restart information

Return type:

SubmittedJobs

Module contents#

class pyslk.jobs.SubmittedJobs(*, submitted_jobs_raw_output: str | None = None, resources: str | Path | list[str] | list[pathlib.Path] | None = None, resource_ids: int | str | list[int] | list[str] | None = None, search_id: int | str | None = None, search_query: str | None = None, json_input_file: str | Path | None = None, recursive: bool = False, resume_on_page: int = 1, results_per_page: int = -1, end_on_page: int = -1, save_mode: bool = False)#

Bases: object

are_completed_details() dict[int, bool]#
are_completed_short() bool#
are_finished_details() dict[int, bool]#
are_finished_short() bool#
are_successful_details() dict[int, bool]#
are_successful_short() bool#
static extract_job_ids(jobs: list[dict]) list[int]#
finished_successfully() bool#
get_job_ids() list[int]#
get_job_information(job_id: int) dict | None#
get_restart_information() dict#
get_search_id() int#
get_search_query() str | None#
get_source() Optional[str, Path, list[int]]#
had_timeout() bool#
has_restart_information() bool#
merge(other: SubmittedJobs)#
missing_restart_information() list[str]#

check whether fields are missing in the available restart information

this json should have been returned by ‘pyslk.submit_verify_jobs_raw’ “restart_information”: {

“search_id”: 613746, “start_page”: 1, “save_mode”: false, “verbose”: false

}

needs_restart() bool#
optional_keys = ['search_query', 'n_max_search_results', 'n_max_verify_jobs', 'n_verify_jobs', 'restart_information']#
required_keys = ['jobs', 'search_id', 'source', 'submitted_all_jobs', 'timeout']#
required_restart_keys = ['search_id', 'start_page', 'save_mode', 'verbose']#
submit(force_save_mode: bool = False)#

submit jobs; fresh start of all jobs and resume interrupted submission

Parameters:

force_save_mode (bool) – force to submit jobs in save mode; forcing non-save mode is not possible by this switch

Returns:

True if all jobs were submitted successfully

Return type:

bool

pyslk.jobs.get_bad_files_verify_job(jobs: int | list[int] | set[int] | SubmittedJobs) dict[str, list[pathlib.Path]]#

Get results of one or more verify jobs

Parameters:

jobs (int or list[int] or set[int] or SubmittedJobs) – submitted jobs (job id, list of job ids or SubmittedJobs object)

Returns:

results of the verify job

Return type:

dict[str, list[Path]]

pyslk.jobs.get_checked_resources_verify_job(jobs: int | list[int] | SubmittedJobs, force_resource_path: bool = False) list[Union[int, pathlib.Path]]#

Get results of one or more verify jobs

TODO: doc update

Parameters:
  • jobs (int or list[int] or SubmittedJobs) – submitted jobs (job id, list of job ids or SubmittedJobs object)

  • force_resource_path (bool) – force resource path to be returned; otherwise, resource ids will be returned (except if a namespace was the target of the verify job which is limited to admins)

Returns:

results of the verify job

Return type:

`list[Union[int, Path]]

pyslk.jobs.get_job_status(job_id: int) StatusJob | None#

Check the status of a job

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

job status; None, if job_id does not exist

Return type:

pyslk.StatusJob or None

pyslk.jobs.get_result_verify_job(job_id: int, return_no_source: bool = False) dict[str, dict]#

Get results of one or more verify jobs

Parameters:
  • job_id (int) – job id

  • return_no_source (bool) – return the result of the verify job but do not contain a list of checked files

Returns:

results of the verify job and its header

Return type:

dict[str, dict]

pyslk.jobs.is_job_finished(job_id: int) bool | None#

Check the status of a tape

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

True if job with job_id is finished; else False

Return type:

bool or None

pyslk.jobs.is_job_processing(job_id: int) bool | None#

Check the status of a tape

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

True if job with job_id is currently being processed; else False

Return type:

bool or None

pyslk.jobs.is_job_queued(job_id: int) bool | None#

Check the status of a tape

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

True if job with job_id is queued; else False

Return type:

bool or None

pyslk.jobs.is_job_successful(job_id: int) bool | None#

Check the status of a tape

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

True if job with job_id is finished and was successful; else False

Return type:

bool or None

pyslk.jobs.job_exists(job_id: int) bool#

Check if job exists

Parameters:

job_id (int) – id of a recall job in StrongLink

Returns:

True if job exists; False otherwise

Return type:

bool

pyslk.jobs.job_queue() dict#

Prints status of the queue of tape read jobs

Returns:

information on the recall job queue (number of queued and processing jobs and some more information)

Return type:

dict

pyslk.jobs.submit_verify_job(resources: str | Path | list[str] | list[pathlib.Path] | None = None, resource_ids: int | str | list[int] | list[str] | None = None, search_id: int | str | None = None, search_query: str | None = None, json_input_file: str | Path | None = None, recursive: bool = False, resume_on_page: int = 1, end_on_page: int = -1, save_mode: bool = False) SubmittedJobs#

Submit a verify job

Parameters:
  • resources (str or Path or list[str] or list[Path] or None) – provide a list of resources over which the verify job should be run

  • resource_ids (str or int or list[str] or list[int] or None) – provide a list of ids of resources over which the verify job should be run

  • search_id (str or int or None) – provide a search id pointing to files over which the verify job should be run

  • search_query (str or None) – provide a search query to select files over which the verify job should be run

  • json_input_file (str or Path or None) – read a JSON file which contains payload of the verify job (admin users only)

  • recursive (bool) – iterate namespaces recursively

  • resume_on_page (int) – resume the command and start with search result page resume_on_page; internally, 1000 search results are on one ‘page’ and fetched by one request; you do not necessarily have read permissions for all of these files

  • end_on_page (int) – end with search result page end_on_page; internally, 1000 search results are on one ‘page’ and fetched by one request; you do not necessarily have read permissions for all of these files

  • save_mode (bool) – save mode suggested to be used in times of many timeouts; please do not regularly use this parameter; start one verify job per page of search results instead of one verify job for 50 pages of search results

Returns:

submitted jobs and, if command failed due to timeout, restart information

Return type:

SubmittedJobs