authorisation_checkers
Authorisation Checkers.
Module
Functions
check_identity_verification_method
def check_identity_verification_method( method: Union[str, IdentityVerificationMethod],) ‑> IdentityVerificationMethod:
Checks that the verification method is supported.
Global variables
DEFAULT_IDENTITY_VERIFICATION_METHOD : Final[str]
- Default identity verification method
IDENTITY_VERIFICATION_METHODS : Final[tuple[str, ...]]
- Allowed types of identity verification as a tuple of strings
Classes
AuthCheckResponse
class AuthCheckResponse( pod_response_message: _PodResponseMessage, protocol_context: ProtocolContext,):
Response regarding an authentication check.
Contains information on whether the task is allowed to run, as well as any other run-time details needed by the task that are provided by the access manager.
Attributes
pod_response_message
: The response of the pod to the task request. Contains information on the modeller, pod, and any messages related to why the task was rejected (if applicable).protocol_context
: Details needed for the protocol at runtime, such as usage limits, etc.
Variables
- static
pod_response_message : bitfount.federated.pod_response_message._PodResponseMessage
- static
protocol_context : ProtocolContext
IdentityVerificationMethod
class IdentityVerificationMethod( value, names=None, *, module=None, qualname=None, type=None, start=1,):
Allowed types of identity verification.
InferenceLimits
class InferenceLimits(limit: int, total_usage: int):
Container class for model inference usage limits.
Attributes
limit
: The total number of inferences that can be performed.total_usage
: The total number of inferences performed so far.
Variables
- static
limit : int
- static
total_usage : int
initial_total_usage : int
- Returns the total usage that was set when this instance was created.
Static methods
from_access_check_result
def from_access_check_result( access_check_result: AccessCheckResult,) ‑> dict[str, InferenceLimits]:
Construct model name -> inference usage limits from access check results.
If a model usage limit
is undefined
or not present, this indicates that
there is no usage limit, and so we do not add this to the constructed dict.
Returns
Dictionary of full model name (e.g. "some-model-owner/some-model:12"
to the model inference usage limits for that model as detailed in
access_check_results
).
ModelURLs
class ModelURLs( model_download_url: _S3PresignedURL, model_weights_url: _S3PresignedURL | None,):
Container class for model download URLs from the authorisation checker.
Attributes
model_download_url
: URL for downloading the model code.model_weights_url
: URL for downloading the model weights.
Variables
- static
model_download_url : bitfount.types._S3PresignedURL
- static
model_weights_url : Optional[bitfount.types._S3PresignedURL]
Static methods
from_access_check_result
def from_access_check_result( access_check_result: AccessCheckResult,) ‑> dict[str, ModelURLs]:
Construct model name -> model download URLs from access check results.
Returns
Dictionary of full model name/id (e.g. "some-model-owner/some-model:12"
to the model download URL and/or model weights URL for that model as
detailed in access_check_results
).
ProtocolContext
class ProtocolContext( inference_limits: dict[str, InferenceLimits] = {}, model_urls: dict[str, ModelURLs] = {}, task_context: Optional[TaskContext] = None,):
Details needed for the protocol at runtime.
Attributes
inference_limits
: A mapping of model name (full name, including owner and version) to the inference limits information for that model. e.g.{"some-model-owner/some-model:12": {"limit": 90, "total_usage": 10}}
task_context
: Optional. Which context (modeller or worker) the task is running in.
Variables
- static
inference_limits : dict[str, InferenceLimits]
- static
model_urls : dict[str, ModelURLs]
- static
task_context : Optional[TaskContext]