compute¶
alchemiscale.compute.client — client for interacting with compute API¶
- class alchemiscale.compute.client.AlchemiscaleComputeClient(api_url: str | None = None, identifier: str | None = None, key: str | None = None, cache_directory: Path | str | None = None, cache_size_limit: int = 1073741824, use_local_cache: bool = True, max_retries: int = 5, retry_base_seconds: float = 2.0, retry_max_seconds: float = 60.0, verify: bool = True)¶
Bases:
AlchemiscaleBaseClientClient for compute service interaction with compute API service.
- claim_taskhub_tasks(taskhub: ScopedKey, compute_service_id: ComputeServiceID, count: int = 1, protocols: list[str] | None = None) Task¶
Claim a Task from the specified TaskHub
- claim_tasks(scopes: list[Scope], compute_service_id: ComputeServiceID, scopes_exclude: list[Scope] | None = None, count: int = 1, protocols: list[str] | None = None)¶
Claim Tasks from TaskHubs within a list of Scopes.
- exception alchemiscale.compute.client.AlchemiscaleComputeClientError(*args, **kwargs)¶
Bases:
AlchemiscaleBaseClientError
- class alchemiscale.compute.client.AlchemiscaleComputeManagerClient(api_url: str | None = None, identifier: str | None = None, key: str | None = None, cache_directory: Path | str | None = None, cache_size_limit: int = 1073741824, use_local_cache: bool = True, max_retries: int = 5, retry_base_seconds: float = 2.0, retry_max_seconds: float = 60.0, verify: bool = True)¶
Bases:
AlchemiscaleBaseClient
- exception alchemiscale.compute.client.AlchemiscaleComputeManagerClientError(*args, **kwargs)¶
Bases:
AlchemiscaleBaseClientError
alchemiscale.compute.service — compute services for FEC execution¶
- class alchemiscale.compute.service.AsynchronousComputeService(api_url)¶
Bases:
SynchronousComputeServiceAsynchronous compute service.
This service can be used in production cases, though it does not make use of Folding@Home.
- start()¶
Start the service; will keep going until told to stop.
- class alchemiscale.compute.service.SynchronousComputeService(settings: ComputeServiceSettings)¶
Bases:
objectFully synchronous compute service.
This service is intended for use as a reference implementation, and for testing/debugging protocols.
- beat()¶
Deliver a heartbeat to the compute API, indicating this service is still alive.
- claim_tasks(count=1) list[ScopedKey | None]¶
Get a Task to execute from compute API.
Returns None if no Task was available matching service configuration.
- Parameters:
count – The maximum number of Tasks to claim.
- execute(task: ScopedKey) ScopedKey¶
Executes given Task.
Returns ScopedKey of ProtocolDAGResultRef following push to database.
- heartbeat()¶
Start up the heartbeat, sleeping for self.heartbeat_interval.
A failing
beat()is logged and the loop continues; the thread only exits onstop()(viaSleepInterrupted) or process teardown. The compute API exposes its own retry policy on the underlying client call, but if those retries are ever exhausted — e.g. a sustained outage or auth-token expiry — a raised exception here would otherwise silently kill the heartbeat thread while the main loop kept processing tasks. Swallow per-beat failures so a transient problem doesn’t deregister the service from the API’s point of view.
- start()¶
Start the service.
The service runs until it is told to stop, or until one of the limits configured on its settings is reached.
max_taskscaps the number of Tasks executed andmax_timecaps the number of seconds run; the first maximum to be hit triggers the service to exit. Either limit beingNone(the default) means no limit of that kind.
- task_to_protocoldag(task: ScopedKey) tuple[ProtocolDAG, Transformation, ProtocolDAGResult | None]¶
Given a Task, produce a corresponding ProtocolDAG that can be executed.
Also gives the Transformation that this ProtocolDAG corresponds to. If the Task extends another Task, then the ProtocolDAGResult for that other Task is also given; otherwise None given.