flip_api.db.models.main_models ============================== .. py:module:: flip_api.db.models.main_models Classes ------- .. autoapisummary:: flip_api.db.models.main_models.FLNets flip_api.db.models.main_models.FLScheduler flip_api.db.models.main_models.FLJobTrust flip_api.db.models.main_models.FLJob flip_api.db.models.main_models.FLMetrics flip_api.db.models.main_models.FLLogs flip_api.db.models.main_models.Model flip_api.db.models.main_models.ModelTrustIntersect flip_api.db.models.main_models.ModelsAudit flip_api.db.models.main_models.ProjectTrustIntersect flip_api.db.models.main_models.Projects flip_api.db.models.main_models.ProjectsAudit flip_api.db.models.main_models.ProjectUserAccess flip_api.db.models.main_models.Queries flip_api.db.models.main_models.QueryResult flip_api.db.models.main_models.QueryStats flip_api.db.models.main_models.SiteBanner flip_api.db.models.main_models.SiteConfig flip_api.db.models.main_models.Trust flip_api.db.models.main_models.TrustsAudit flip_api.db.models.main_models.FLKitSlot flip_api.db.models.main_models.TrustTask flip_api.db.models.main_models.UploadedFiles flip_api.db.models.main_models.XNATProjectStatus Module Contents --------------- .. py:class:: FLNets Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'fl_nets' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: name :type: str .. py:attribute:: endpoint :type: str .. py:attribute:: fl_backend :type: flip_api.domain.schemas.types.FLBackend .. py:attribute:: schedulers :type: list[FLScheduler] .. py:class:: FLScheduler Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'fl_scheduler' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: net_id :type: uuid.UUID .. py:attribute:: status :type: flip_api.domain.schemas.status.NetStatus .. py:attribute:: job_id :type: uuid.UUID | None .. py:attribute:: job :type: Optional[FLJob] .. py:attribute:: net :type: Optional[FLNets] .. py:class:: FLJobTrust Bases: :py:obj:`sqlmodel.SQLModel` Many-to-many link between FLJob and Trust: the trusts selected for a training run. .. py:attribute:: __tablename__ :value: 'fl_job_trust' .. py:attribute:: fl_job_id :type: uuid.UUID .. py:attribute:: trust_id :type: uuid.UUID .. py:class:: FLJob Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'fl_job' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: model_id :type: uuid.UUID .. py:attribute:: status :type: flip_api.domain.schemas.status.JobStatus .. py:attribute:: created :type: Annotated[datetime.datetime, Field(default_factory=datetime.utcnow)] .. py:attribute:: started :type: datetime.datetime | None .. py:attribute:: completed :type: datetime.datetime | None .. py:attribute:: fl_backend_job_id :type: str | None :value: None .. py:attribute:: scheduler :type: Optional[FLScheduler] .. py:attribute:: trusts :type: list[Trust] .. py:class:: FLMetrics Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'fl_metrics' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: trust :type: uuid.UUID .. py:attribute:: fl_client_name :type: str .. py:attribute:: model_id :type: uuid.UUID .. py:attribute:: global_round :type: int .. py:attribute:: timestamp :type: datetime.datetime | None .. py:attribute:: label :type: str .. py:attribute:: result :type: float .. py:class:: FLLogs Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'fl_logs' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: model_id :type: uuid.UUID .. py:attribute:: log_date :type: Annotated[datetime.datetime | None, Field(default_factory=datetime.utcnow)] .. py:attribute:: success :type: bool .. py:attribute:: trust :type: uuid.UUID | None .. py:attribute:: fl_client_name :type: str | None .. py:attribute:: log :type: str .. py:class:: Model Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'model' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: name :type: str .. py:attribute:: description :type: str .. py:attribute:: status :type: flip_api.domain.schemas.status.ModelStatus .. py:attribute:: deleted :type: bool .. py:attribute:: project_id :type: uuid.UUID | None .. py:attribute:: owner_id :type: uuid.UUID .. py:attribute:: creation_timestamp :type: Annotated[datetime.datetime, Field(default_factory=datetime.utcnow)] .. py:class:: ModelTrustIntersect Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'model_trust_intersect' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: status :type: flip_api.domain.schemas.status.TrustIntersectStatus .. py:attribute:: model_id :type: uuid.UUID | None .. py:attribute:: trust_id :type: uuid.UUID | None .. py:attribute:: fl_client_endpoint :type: str | None .. py:class:: ModelsAudit Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'models_audit' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: model_id :type: uuid.UUID | None .. py:attribute:: action :type: flip_api.domain.schemas.actions.ModelAuditAction .. py:attribute:: user_id :type: uuid.UUID | None .. py:attribute:: audit_date :type: Annotated[datetime.datetime, Field(default_factory=lambda: datetime.now(timezone.utc))] .. py:class:: ProjectTrustIntersect Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'project_trust_intersect' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: project_id :type: uuid.UUID | None .. py:attribute:: trust_id :type: uuid.UUID | None .. py:attribute:: approved :type: bool .. py:attribute:: approved_at :type: datetime.datetime | None .. py:class:: Projects Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'projects' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: name :type: str .. py:attribute:: description :type: str .. py:attribute:: owner_id :type: uuid.UUID .. py:attribute:: deleted :type: bool .. py:attribute:: creation_timestamp :type: Annotated[datetime.datetime, Field(default_factory=datetime.utcnow)] .. py:attribute:: status :type: flip_api.domain.schemas.status.ProjectStatus .. py:attribute:: dicom_to_nifti :type: bool .. py:class:: ProjectsAudit Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'projects_audit' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: project_id :type: uuid.UUID | None .. py:attribute:: action :type: flip_api.domain.schemas.actions.ProjectAuditAction .. py:attribute:: user_id :type: uuid.UUID .. py:attribute:: audit_date :type: Annotated[datetime.datetime, Field(default_factory=lambda: datetime.now(timezone.utc))] .. py:class:: ProjectUserAccess Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'project_user_access' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: project_id :type: uuid.UUID | None .. py:attribute:: user_id :type: uuid.UUID .. py:class:: Queries Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'queries' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: name :type: str .. py:attribute:: query :type: str .. py:attribute:: created :type: Annotated[datetime.datetime, Field(default_factory=datetime.utcnow)] .. py:attribute:: created_by :type: uuid.UUID .. py:attribute:: project_id :type: uuid.UUID | None .. py:attribute:: queried_trust_ids :type: list[uuid.UUID] .. py:class:: QueryResult Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'query_result' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: query_id :type: uuid.UUID .. py:attribute:: trust_id :type: uuid.UUID | None .. py:attribute:: data :type: str .. py:class:: QueryStats Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'query_stats' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: stats :type: str .. py:attribute:: stats_received :type: Annotated[datetime.datetime, Field(default_factory=datetime.utcnow)] .. py:attribute:: query_id :type: uuid.UUID .. py:class:: SiteBanner Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'site_banner' .. py:attribute:: id :type: int .. py:attribute:: message :type: str .. py:attribute:: link :type: str | None :value: None .. py:attribute:: enabled :type: bool .. py:class:: SiteConfig Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'site_config' .. py:attribute:: key :type: str .. py:attribute:: value :type: bool .. py:class:: Trust Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'trust' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: name :type: str .. py:attribute:: last_heartbeat :type: datetime.datetime | None .. py:attribute:: code :type: str | None .. py:attribute:: region :type: str | None .. py:attribute:: api_key_hash :type: str | None .. py:attribute:: created_at :type: datetime.datetime .. py:class:: TrustsAudit Bases: :py:obj:`sqlmodel.SQLModel` Audit log for trust-registry mutations (register / delete). Captures lifecycle events on `trust`: admin-UI `POST /admin/trusts`, deploy-CLI `register_trust.py`, and deploy-CLI `delete_trust.py`. Rows survive a hard delete of the underlying trust — `trust_id` is a bare UUID with NO foreign key, so the audit row remains queryable after the `trust` row is gone (delete_trust.py hard-deletes; an FK would either block that delete or null this column out). `modified_by_user_id` is nullable because the deploy-CLI path runs on a bastion under operator IAM, not an authenticated FLIP user: both `register_trust.py` and `delete_trust.py` write NULL. The UI path (`admin_create_trust`) stamps the Cognito sub of the authenticated admin. `trust_name` is denormalised here on purpose: it lets audit queries show a human-readable name long after the trust row was hard-deleted. .. py:attribute:: __tablename__ :value: 'trusts_audit' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: trust_id :type: uuid.UUID .. py:attribute:: trust_name :type: str .. py:attribute:: action :type: flip_api.domain.schemas.actions.TrustAuditAction .. py:attribute:: modified_by_user_id :type: uuid.UUID | None .. py:attribute:: audit_date :type: Annotated[datetime.datetime, Field(default_factory=lambda: datetime.now(timezone.utc))] .. py:class:: FLKitSlot Bases: :py:obj:`sqlmodel.SQLModel` Pool of pre-provisioned FL participant kits the hub assigns to joining trusts. Decouples the hub-side trust identity (``Trust.name``, arbitrary admin-chosen) from the FL participant identity (the CN baked into the kit's cert at provisioning time). Operators get matching ``services//`` dirs on every net's workspace — one global slot row covers all nets, so the assignment doesn't need a net_id column. Lifecycle: rows are seeded from ``FL_KIT_SLOT_NAMES`` (one per pre-provisioned slot in flip-fl-base). ``POST /admin/trusts`` claims the next ``assigned_to_trust_id IS NULL`` row in the same transaction as the trust insert. .. py:attribute:: __tablename__ :value: 'fl_kit_slot' .. py:attribute:: slot_name :type: str .. py:attribute:: slot_number :type: int .. py:attribute:: assigned_to_trust_id :type: uuid.UUID | None .. py:attribute:: assigned_at :type: datetime.datetime | None .. py:class:: TrustTask Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'trust_task' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: trust_id :type: uuid.UUID .. py:attribute:: task_type :type: flip_api.domain.schemas.status.TaskType .. py:attribute:: payload :type: str .. py:attribute:: query_id :type: uuid.UUID | None .. py:attribute:: status :type: flip_api.domain.schemas.status.TaskStatus .. py:attribute:: result :type: str | None .. py:attribute:: needs_post_processing :type: bool .. py:attribute:: retry_count :type: int .. py:attribute:: created_at :type: Annotated[datetime.datetime, Field(default_factory=lambda: datetime.now(timezone.utc))] .. py:attribute:: updated_at :type: datetime.datetime | None .. py:class:: UploadedFiles Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'uploaded_files' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: name :type: str .. py:attribute:: status :type: flip_api.domain.schemas.file.FileUploadStatus .. py:attribute:: size :type: float .. py:attribute:: type :type: str .. py:attribute:: tag :type: str | None .. py:attribute:: model_id :type: uuid.UUID | None .. py:class:: XNATProjectStatus Bases: :py:obj:`sqlmodel.SQLModel` .. py:attribute:: __tablename__ :value: 'xnat_project_status' .. py:attribute:: id :type: uuid.UUID .. py:attribute:: xnat_project_id :type: uuid.UUID .. py:attribute:: project_id :type: uuid.UUID | None .. py:attribute:: trust_id :type: uuid.UUID | None .. py:attribute:: retrieve_image_status :type: flip_api.domain.schemas.status.XNATImageStatus .. py:attribute:: query_at_creation :type: uuid.UUID | None .. py:attribute:: last_reimport :type: Annotated[datetime.datetime, Field(default_factory=lambda: datetime.now(timezone.utc))] .. py:attribute:: reimport_count :type: int