flip.core.standard
Standard FLIP Implementation.
This module contains the production and development implementations of FLIP for the standard, evaluation, and fed_opt job types.
Classes
Production implementation of FLIP for standard job types. |
|
Development implementation of FLIP for standard job types. |
Module Contents
- class flip.core.standard.FLIPStandardProd[source]
Bases:
flip.core.base.FLIPBaseProduction implementation of FLIP for standard job types.
Method usage by FL role:
- Server-only (fl-server on Central Hub → calls flip-api):
update_status()— update model training statussend_metrics()— forward per-client training/evaluation metricssend_handled_exception()— forward client exception logsupload_results_to_s3()— upload trained model to S3
- Client-only (fl-client on trust side → calls local trust APIs):
get_dataframe()— fetch cohort data from data-access-apiget_images()— download images from imaging-apidownload_data_from_s3()— download federated data from S3
- get_dataframe(project_id: str, query: str) pandas.DataFrame[source]
Retrieves the dataframe from the trust OMOP using the SQL query. Calls the FLIP data-access-api.
- get_by_accession_number(project_id: str, accession_id: str, resource_type: flip.constants.flip_constants.ResourceType | List[flip.constants.flip_constants.ResourceType] = ResourceType.NIFTI) pathlib.Path[source]
Calls the imaging-service to return a filepath that contains images downloaded from XNAT based on the accession number.
- Parameters:
project_id (str) – The ID of the project.
accession_id (str) – The accession ID of the imaging study.
resource_type (Union[ResourceType, List[ResourceType]]) – The type of resource to download. Defaults to
ResourceType.NIFTI.
- Returns:
Path – Path to the downloaded data for that accession_id.
- add_resource(project_id: str, accession_id: str, scan_id: str, resource_id: str, files: List[str]) None[source]
Calls the imaging-service to upload image(s) to XNAT based on the accession number, scan ID, and resource ID.
- update_status(model_id: str, new_model_status: flip.constants.flip_constants.ModelStatus) None[source]
Updates the model status on the Central Hub.
- Parameters:
model_id (str) – Unique model identifier.
new_model_status (ModelStatus) – New model status value.
- send_metrics(client_name: str, model_id: str, label: str, value: float, round: int) None[source]
Sends a metric value to the Central Hub.
- send_handled_exception(formatted_exception: str, client_name: str, model_id: str) None[source]
Sends a handled exception to the Central Hub.
- upload_results_to_s3(results_folder: pathlib.Path, model_id: str) None[source]
Uploads results to S3 bucket in standard mode.
- Parameters:
results_folder (Path) – The folder containing results to upload
model_id (str) – The model UUID for which results are being uploaded
- cleanup(path: pathlib.Path) None[source]
Cleans up local files by deleting the specified path.
- class flip.core.standard.FLIPStandardDev[source]
Bases:
flip.core.base.FLIPBaseDevelopment implementation of FLIP for standard job types.
- get_dataframe(project_id: str, query: str) pandas.DataFrame[source]
Retrieves the dataframe from the specified CSV path.
- get_by_accession_number(project_id: str, accession_id: str, resource_type: flip.constants.flip_constants.ResourceType | List[flip.constants.flip_constants.ResourceType] = ResourceType.NIFTI) pathlib.Path[source]
Returns the path to the image directory for a specific accession ID.
- Parameters:
project_id (str) – Project identifier
accession_id (str) – Accession ID to retrieve
resource_type (Union[ResourceType, List[ResourceType]]) – Type of imaging resource (not used in dev)
- Returns:
Path – Path to the accession_id folder within the images folder.
- add_resource(project_id: str, accession_id: str, scan_id: str, resource_id: str, files: List[str]) None[source]
Log only in dev mode - no actual upload.
- update_status(model_id: str, new_model_status: flip.constants.flip_constants.ModelStatus) None[source]
Log only in dev mode - no actual status update.
- send_metrics(client_name: str, model_id: str, label: str, value: float, round: int) None[source]
Log only in dev mode - no actual metrics sending.
- send_handled_exception(formatted_exception: str, client_name: str, model_id: str) None[source]
Log only in dev mode - no actual exception sending.
- upload_results_to_s3(results_folder: pathlib.Path, model_id: str) None[source]
Log only in dev mode - no actual upload.
- cleanup(path: pathlib.Path) None[source]
Log only in dev mode - no actual deletion of any files.