flip.core.standard ================== .. py:module:: flip.core.standard .. autoapi-nested-parse:: Standard FLIP Implementation. This module contains the production and development implementations of FLIP for the standard, evaluation, and fed_opt job types. Classes ------- .. autoapisummary:: flip.core.standard.FLIPStandardProd flip.core.standard.FLIPStandardDev Module Contents --------------- .. py:class:: FLIPStandardProd Bases: :py:obj:`flip.core.base.FLIPBase` Production 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 status - ``send_metrics()`` — forward per-client training/evaluation metrics - ``send_handled_exception()`` — forward client exception logs - ``upload_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-api - ``get_images()`` — download images from imaging-api - ``download_data_from_s3()`` — download federated data from S3 .. py:attribute:: logger .. py:method:: get_dataframe(project_id: str, query: str) -> pandas.DataFrame Retrieves the dataframe from the trust OMOP using the SQL query. Calls the FLIP data-access-api. :param project_id: Project identifier :type project_id: str :param query: SQL query :type query: str :returns: *pd.DataFrame* -- Dataframe containing the resulting accession ids and additional data. .. py:method:: get_by_accession_number(project_id: str, accession_id: str, resource_type: Union[flip.constants.flip_constants.ResourceType, List[flip.constants.flip_constants.ResourceType]] = ResourceType.NIFTI) -> pathlib.Path Calls the imaging-service to return a filepath that contains images downloaded from XNAT based on the accession number. :param project_id: The ID of the project. :type project_id: str :param accession_id: The accession ID of the imaging study. :type accession_id: str :param resource_type: The type of resource to download. Defaults to :type resource_type: Union[ResourceType, List[ResourceType]] :param ResourceType.NIFTI.: :returns: *Path* -- Path to the downloaded data for that accession_id. .. py:method:: add_resource(project_id: str, accession_id: str, scan_id: str, resource_id: str, files: List[str]) -> None Calls the imaging-service to upload image(s) to XNAT based on the accession number, scan ID, and resource ID. :param project_id: Unique project identifier :type project_id: str :param accession_id: Accession ID to upload the resource to :type accession_id: str :param scan_id: ID of the scan to upload :type scan_id: str :param resource_id: Type of resource that is being uploaded (e.g. NIFTI) :type resource_id: str :param files: List of files to upload :type files: List[str] .. py:method:: update_status(model_id: str, new_model_status: flip.constants.flip_constants.ModelStatus) -> None Updates the model status on the Central Hub. :param model_id: Unique model identifier. :type model_id: str :param new_model_status: New model status value. :type new_model_status: ModelStatus .. py:method:: send_metrics(client_name: str, model_id: str, label: str, value: float, round: int) -> None Sends a metric value to the Central Hub. :param client_name: The name of the client. :type client_name: str :param model_id: The ID of the model. :type model_id: str :param label: The label of the metric. :type label: str :param value: The value of the metric. :type value: float :param round: The round number. :type round: int .. py:method:: send_handled_exception(formatted_exception: str, client_name: str, model_id: str) -> None Sends a handled exception to the Central Hub. :param formatted_exception: The formatted exception message. :type formatted_exception: str :param client_name: The name of the client that raised the exception. :type client_name: str :param model_id: The ID of the model associated with the exception. :type model_id: str .. py:method:: upload_results_to_s3(results_folder: pathlib.Path, model_id: str) -> None Uploads results to S3 bucket in standard mode. :param results_folder: The folder containing results to upload :type results_folder: Path :param model_id: The model UUID for which results are being uploaded :type model_id: str .. py:method:: cleanup(path: pathlib.Path) -> None Cleans up local files by deleting the specified path. .. py:class:: FLIPStandardDev Bases: :py:obj:`flip.core.base.FLIPBase` Development implementation of FLIP for standard job types. .. py:attribute:: logger .. py:method:: get_dataframe(project_id: str, query: str) -> pandas.DataFrame Retrieves the dataframe from the specified CSV path. :param project_id: Project identifier (validated but not used in dev) :type project_id: str :param query: SQL query (validated but not used in dev) :type query: str :returns: *pd.DataFrame* -- Dataframe from the DEV_DATAFRAME CSV file. .. py:method:: get_by_accession_number(project_id: str, accession_id: str, resource_type: Union[flip.constants.flip_constants.ResourceType, List[flip.constants.flip_constants.ResourceType]] = ResourceType.NIFTI) -> pathlib.Path Returns the path to the image directory for a specific accession ID. :param project_id: Project identifier :type project_id: str :param accession_id: Accession ID to retrieve :type accession_id: str :param resource_type: Type of imaging resource (not used in dev) :type resource_type: Union[ResourceType, List[ResourceType]] :returns: *Path* -- Path to the accession_id folder within the images folder. .. py:method:: add_resource(project_id: str, accession_id: str, scan_id: str, resource_id: str, files: List[str]) -> None Log only in dev mode - no actual upload. .. py:method:: update_status(model_id: str, new_model_status: flip.constants.flip_constants.ModelStatus) -> None Log only in dev mode - no actual status update. .. py:method:: send_metrics(client_name: str, model_id: str, label: str, value: float, round: int) -> None Log only in dev mode - no actual metrics sending. .. py:method:: send_handled_exception(formatted_exception: str, client_name: str, model_id: str) -> None Log only in dev mode - no actual exception sending. .. py:method:: upload_results_to_s3(results_folder: pathlib.Path, model_id: str) -> None Log only in dev mode - no actual upload. .. py:method:: cleanup(path: pathlib.Path) -> None Log only in dev mode - no actual deletion of any files.