flip_api.domain.interfaces.fl ============================= .. py:module:: flip_api.domain.interfaces.fl Attributes ---------- .. autoapisummary:: flip_api.domain.interfaces.fl.DEFAULT_JOB_TYPE flip_api.domain.interfaces.fl.ASSETS_DIR Classes ------- .. autoapisummary:: flip_api.domain.interfaces.fl.IStartTrainingBody flip_api.domain.interfaces.fl.ISchedulerResponse flip_api.domain.interfaces.fl.IJobResponse flip_api.domain.interfaces.fl.IJobMetaData flip_api.domain.interfaces.fl.IRequiredTrainingInformation flip_api.domain.interfaces.fl.IInitiateTrainingInputPayload flip_api.domain.interfaces.fl.INetDetails flip_api.domain.interfaces.fl.IServerStatus flip_api.domain.interfaces.fl.IClientStatus flip_api.domain.interfaces.fl.INetStatus flip_api.domain.interfaces.fl.IOverridableConfig flip_api.domain.interfaces.fl.FLAggregators flip_api.domain.interfaces.fl.AggregationWeights flip_api.domain.interfaces.fl.JobRequiredFiles Functions --------- .. autoapisummary:: flip_api.domain.interfaces.fl.required_job_types_file flip_api.domain.interfaces.fl._load_job_types_config Module Contents --------------- .. py:data:: DEFAULT_JOB_TYPE :value: 'standard' .. py:data:: ASSETS_DIR .. py:function:: required_job_types_file(fl_backend: flip_api.domain.schemas.types.FLBackend) -> pathlib.Path Local path of the per-backend job-types/required-files manifest. :param fl_backend: The FL backend the manifest belongs to (``nvflare`` or ``flower``). :type fl_backend: FLBackend :returns: Absolute path to the per-backend manifest under the assets directory. :rtype: Path .. py:function:: _load_job_types_config(fl_backend: flip_api.domain.schemas.types.FLBackend) -> dict[str, list[str]] Loads the job types configuration for a backend from its on-disk manifest. The manifest is pulled from S3 at runtime; if it is missing (e.g. S3 was unreachable when the model was created) an empty mapping is returned so the API does not crash. :param fl_backend: The FL backend whose manifest to load (``nvflare`` or ``flower``). :type fl_backend: FLBackend :returns: A dictionary mapping job type names to their required files, or an empty dict if the manifest is absent or malformed. :rtype: dict[str, list[str]] .. py:class:: IStartTrainingBody Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: project_id :type: str .. py:attribute:: cohort_query :type: str .. py:attribute:: trusts :type: list[str] .. py:attribute:: bundle_urls :type: list[str] .. py:class:: ISchedulerResponse Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: id :type: uuid.UUID .. py:attribute:: netId :type: uuid.UUID .. py:class:: IJobResponse Bases: :py:obj:`pydantic.BaseModel` Internal handoff from `check_for_queued_jobs` to `prepare_and_start_training`. Carries the trust ids that were attached to the FL job via the `fl_job_trust` link table; `prepare_and_start_training` re-fetches the Trust rows from the DB before talking to the FL backend, so we don't try to ferry ORM objects through a Pydantic schema. .. py:attribute:: id :type: uuid.UUID .. py:attribute:: model_id :type: uuid.UUID .. py:attribute:: trust_ids :type: list[uuid.UUID] .. py:class:: IJobMetaData Bases: :py:obj:`pydantic.BaseModel` Job metadata as returned by an FL-API adapter's ``GET /list_jobs``. The shared job-metadata contract (GitHub issue #490). flip-api correlates ``model_id`` <-> ``job_id`` in its own ``fl_job`` table, so the contract carries only ``job_id`` + ``status``. .. py:attribute:: model_config .. py:attribute:: job_id :type: str .. py:attribute:: status :type: flip_api.domain.schemas.status.FLJobStatus .. py:class:: IRequiredTrainingInformation Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: project_id :type: str .. py:attribute:: cohort_query :type: str .. py:class:: IInitiateTrainingInputPayload Bases: :py:obj:`pydantic.BaseModel` Request body for `POST /fl/initiate/{model_id}`. The selected trusts are the FL participants for this training run. Trusts are identified by their UUID `id` (not name): names are admin-chosen, non-unique, and may contain arbitrary characters, so they are unsafe to match on. The ids are looked up against the `trust` table at request time — see `initiate_training` for the existence check. .. py:attribute:: model_config .. py:attribute:: trust_ids :type: list[uuid.UUID] .. py:method:: must_be_unique(v: list[uuid.UUID]) -> list[uuid.UUID] :classmethod: .. py:class:: INetDetails Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: name :type: str .. py:attribute:: endpoint :type: str .. py:attribute:: fl_backend :type: flip_api.domain.schemas.types.FLBackend .. py:class:: IServerStatus Bases: :py:obj:`pydantic.BaseModel` Defines the status of the server. .. py:attribute:: model_config .. py:attribute:: status :type: str .. py:class:: IClientStatus Bases: :py:obj:`pydantic.BaseModel` Defines the status of a client. .. py:attribute:: model_config .. py:attribute:: name :type: str .. py:attribute:: code :type: str | None :value: None .. py:attribute:: status :type: str .. py:attribute:: fl_kit_slot :type: str | None :value: None .. py:property:: online :type: bool .. py:class:: INetStatus Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: name :type: str .. py:attribute:: fl_backend :type: flip_api.domain.schemas.types.FLBackend .. py:attribute:: online :type: bool | None :value: None .. py:attribute:: registered_clients :type: int | None :value: None .. py:attribute:: net_in_use :type: bool | None :value: None .. py:attribute:: clients :type: list[IClientStatus] .. py:class:: IOverridableConfig Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: LOCAL_ROUNDS :type: int | None :value: None .. py:attribute:: GLOBAL_ROUNDS :type: int | None :value: None .. py:attribute:: IGNORE_RESULT_ERROR :type: bool | None :value: None .. py:attribute:: AGGREGATOR :type: str | None :value: None .. py:attribute:: AGGREGATION_WEIGHTS :type: dict[str, float] | None :value: None .. py:class:: FLAggregators(*args, **kwds) Bases: :py:obj:`enum.Enum` Enumeration for different FL aggregators .. py:attribute:: InTimeAccumulateWeightedAggregator :value: 'InTimeAccumulateWeightedAggregator' .. py:attribute:: AccumulateWeightedAggregator :value: 'AccumulateWeightedAggregator' .. py:class:: AggregationWeights .. py:attribute:: MinimumAggregationWeight :value: 0 .. py:attribute:: MaximumAggregationWeight :value: 1 .. py:class:: JobRequiredFiles Bases: :py:obj:`pydantic.BaseModel` .. py:method:: get_required_files(job_type: str, fl_backend: flip_api.domain.schemas.types.FLBackend) -> list[str] :classmethod: Returns the list of required files for a job type on a given backend. Always reloads from the per-backend on-disk manifest. :param job_type: The job type to look up. :type job_type: str :param fl_backend: The FL backend whose manifest to read (``nvflare`` or ``flower``). :type fl_backend: FLBackend :returns: Required file names for ``job_type``, or an empty list if the job type (or the manifest) is not present on disk. :rtype: list[str] .. py:method:: is_valid_job_type(job_type: str, fl_backend: flip_api.domain.schemas.types.FLBackend) -> bool :classmethod: Whether ``job_type`` is defined in the backend's on-disk manifest. The set of valid job types is data (the manifest keys), not a hard-coded enum, so adding a job type is purely an S3 manifest + base-application change. :param job_type: The job type to validate. :type job_type: str :param fl_backend: The FL backend whose manifest to read (``nvflare`` or ``flower``). :type fl_backend: FLBackend :returns: True if ``job_type`` is a key in the backend's manifest. :rtype: bool .. py:method:: get_all_job_types_with_files(fl_backend: flip_api.domain.schemas.types.FLBackend) -> dict[str, list[str]] :classmethod: Returns all job types with their required files for a given backend. Always reloads from the per-backend on-disk manifest. :param fl_backend: The FL backend whose manifest to read (``nvflare`` or ``flower``). :type fl_backend: FLBackend :returns: A copy of the on-disk mapping of job type names to their required files. :rtype: dict[str, list[str]]