aistore.sdk.job

View as Markdown

Module Contents

Classes

NameDescription
JobA class containing job-related functions.

Data

logger

API

class aistore.sdk.job.Job(
client: aistore.sdk.request_client.RequestClient,
job_id: str = '',
job_kind: str = ''
)

A class containing job-related functions.

Parameters:

client
RequestClient

Client for interfacing with AIS cluster

job_id
strDefaults to ''

ID of a specific job, empty for all jobs

job_kind
strDefaults to ''

Specific kind of job, empty for all kinds

job_id

Return job id

job_kind

Return job kind

aistore.sdk.job.Job._wait_for_condition(
condition_fn,
timeout: int,
verbose: bool,
state: str
) -> aistore.sdk.wait_result.WaitResult
aistore.sdk.job.Job.get_details() -> aistore.sdk.types.AggregatedJobSnap

Retrieve detailed job snapshot information across all targets.

Returns: AggregatedJobSnap

A snapshot containing detailed metrics for the job.

aistore.sdk.job.Job.get_total_time() -> typing.Optional[datetime.timedelta]

Calculates the total job duration as the difference between the earliest start time and the latest end time among all job snapshots. If any snapshot is missing an end_time, returns None to indicate the job is incomplete.

Returns: Optional[timedelta]

Optional[timedelta]: The total duration of the job, or None if incomplete.

aistore.sdk.job.Job.get_within_timeframe(
start_time: datetime.datetime,
end_time: typing.Optional[datetime.datetime] = None
) -> typing.List[aistore.sdk.types.JobSnap]

Retrieves jobs that started after a specified start_time and optionally ended before a specified end_time.

Parameters:

start_time
datetime

The start of the timeframe for monitoring jobs.

end_time
datetimeDefaults to None

The end of the timeframe for monitoring jobs.

Returns: List[JobSnap]

List[JobSnapshot]: A list of jobs that meet the specified timeframe criteria.

Raises:

  • JobInfoNotFound: Raised when no relevant job info is found.
aistore.sdk.job.Job.start(
daemon_id: str = '',
force: bool = False,
buckets: typing.Optional[typing.List[aistore.sdk.bucket.Bucket]] = None
) -> str

Start a job and return its ID.

Parameters:

daemon_id
strDefaults to ''

For running a job that must run on a specific target node (e.g. resilvering).

force
boolDefaults to False

Override existing restrictions for a bucket (e.g., run LRU eviction even if the bucket has LRU disabled).

buckets
List[Bucket]Defaults to None

List of one or more buckets; applicable only for jobs that have bucket scope (for details on job types, see Table in xact/api.go).

Returns: str

The running job ID.

Raises:

  • requests.RequestException: “There was an ambiguous exception that occurred while handling…”
  • requests.ConnectionError: Connection error
  • requests.ConnectionTimeout: Timed out connecting to AIStore
  • requests.ReadTimeout: Timed out waiting response from AIStore
aistore.sdk.job.Job.status() -> aistore.sdk.types.JobStatus

Return status of a job

Returns: JobStatus

The job status including id, finish time, and error info

Raises:

  • ValueError: If the job does not have an assigned ID
  • requests.RequestException: “There was an ambiguous exception that occurred while handling…”
  • requests.ConnectionError: Connection error
  • requests.ConnectionTimeout: Timed out connecting to AIStore
  • requests.ReadTimeout: Timed out waiting response from AIStore
aistore.sdk.job.Job.wait(
timeout: int = DEFAULT_JOB_WAIT_TIMEOUT,
verbose: bool = True
) -> aistore.sdk.wait_result.WaitResult

Wait for a job to finish

Parameters:

timeout
intDefaults to DEFAULT_JOB_WAIT_TIMEOUT

The maximum time to wait for the job, in seconds. Default timeout is 5 minutes.

verbose
boolDefaults to True

Whether to log wait status to standard output

Returns: WaitResult

Outcome of the wait operation

Raises:

  • requests.RequestException: “There was an ambiguous exception that occurred while handling…”
  • requests.ConnectionError: Connection error
  • requests.ConnectionTimeout: Timed out connecting to AIStore
  • requests.ReadTimeout: Timed out waiting response from AIStore
  • errors.Timeout: Timeout while waiting for the job to finish
aistore.sdk.job.Job.wait_for_idle(
timeout: int = DEFAULT_JOB_WAIT_TIMEOUT,
verbose: bool = True
) -> aistore.sdk.wait_result.WaitResult

Wait for a job to reach an idle state

Parameters:

timeout
intDefaults to DEFAULT_JOB_WAIT_TIMEOUT

The maximum time to wait for the job, in seconds. Default timeout is 5 minutes.

verbose
boolDefaults to True

Whether to log wait status to standard output

Returns: WaitResult

Outcome of the wait operation

Raises:

  • requests.RequestException: “There was an ambiguous exception that occurred while handling…”
  • requests.ConnectionError: Connection error
  • requests.ConnectionTimeout: Timed out connecting to AIStore
  • requests.ReadTimeout: Timed out waiting response from AIStore
  • errors.Timeout: Timeout while waiting for the job to finish
aistore.sdk.job.Job.wait_single_node(
timeout: int = DEFAULT_JOB_WAIT_TIMEOUT,
verbose: bool = True
) -> aistore.sdk.wait_result.WaitResult

Wait for a job running on a single node

Parameters:

timeout
intDefaults to DEFAULT_JOB_WAIT_TIMEOUT

The maximum time to wait for the job, in seconds. Default timeout is 5 minutes.

verbose
boolDefaults to True

Whether to log wait status to standard output

Returns: WaitResult

Outcome of the wait operation

Raises:

  • requests.RequestException: “There was an ambiguous exception that occurred while handling…”
  • requests.ConnectionError: Connection error
  • requests.ConnectionTimeout: Timed out connecting to AIStore
  • requests.ReadTimeout: Timed out waiting response from AIStore
  • errors.Timeout: Timeout while waiting for the job to finish
aistore.sdk.job.logger = get_logger(__name__)