flip.core.base ============== .. py:module:: flip.core.base .. autoapi-nested-parse:: FLIP Base Classes. This module contains the abstract base class for all FLIP implementations. Classes ------- .. autoapisummary:: flip.core.base.FLIPBase Module Contents --------------- .. py:class:: FLIPBase Bases: :py:obj:`abc.ABC` Abstract base class for FLIP functionality across all job types. This class defines the interface that all FLIP implementations must follow. Concrete implementations handle the differences between development and production environments, as well as job-type-specific behavior. .. py:attribute:: logger .. py:method:: get_dataframe(project_id: str, query: str) -> pandas.DataFrame :abstractmethod: Returns a dataframe for the project/query. :param project_id: The project identifier :type project_id: str :param query: SQL query string :type query: str :returns: *pd.DataFrame* -- Dataframe containing the query results .. 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 :abstractmethod: Returns the path to the data for the given accession number. :param project_id: The project identifier :type project_id: str :param accession_id: The accession ID of the imaging study :type accession_id: str :param resource_type: Type(s) of resources to download :type resource_type: Union[ResourceType, List[ResourceType]] :returns: *Path* -- Path to the downloaded data .. py:method:: add_resource(project_id: str, accession_id: str, scan_id: str, resource_id: str, files: List[str]) -> None :abstractmethod: Adds specific image to XNAT for an accession ID. :param project_id: The project identifier :type project_id: str :param accession_id: The accession ID :type accession_id: str :param scan_id: The scan ID :type scan_id: str :param resource_id: The resource type ID :type resource_id: str :param files: List of file paths to upload :type files: List[str] .. py:method:: update_status(model_id: str, new_model_status: flip.constants.flip_constants.ModelStatus) -> None :abstractmethod: Updates training status in Central Hub. :param model_id: The model UUID :type model_id: str :param new_model_status: The new status to set :type new_model_status: ModelStatus .. py:method:: send_metrics(client_name: str, model_id: str, label: str, value: float, round: int) -> None :abstractmethod: Sends a metric value to the Central Hub. :param client_name: The client name sending the metric :type client_name: str :param model_id: The model UUID :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 local round number :type round: int .. py:method:: send_handled_exception(formatted_exception: str, client_name: str, model_id: str) -> None :abstractmethod: Sends a training-related exception to Central Hub. :param formatted_exception: The formatted exception message :type formatted_exception: str :param client_name: The client name that raised the exception :type client_name: str :param model_id: The model UUID :type model_id: str .. py:method:: upload_results_to_s3(results_folder: pathlib.Path, model_id: str) -> None :abstractmethod: Uploads results to S3 bucket. :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 :abstractmethod: Cleans up local files. :param path: The path to the file or directory to clean up :type path: Path .. py:method:: check_query(query: str) -> None Check whether the query is a string type. :param query: The query to validate :type query: str :raises TypeError: If query is not a string .. py:method:: check_project_id(project_id: str) -> None Checks whether the project id is a string type. :param project_id: The project ID to validate :type project_id: str :raises TypeError: If project_id is not a string .. py:method:: check_accession_id(accession_id: str) -> None Checks whether accession_id is a string type. :param accession_id: The accession ID to validate :type accession_id: str :raises TypeError: If accession_id is not a string .. py:method:: check_resource_type(resource_type: Union[flip.constants.flip_constants.ResourceType, List[flip.constants.flip_constants.ResourceType]]) -> List[flip.constants.flip_constants.ResourceType] Check whether resource type is valid and returns them reformatted. :param resource_type: Single ResourceType or list of ResourceTypes :type resource_type: Union[ResourceType, List[ResourceType]] :returns: *List[ResourceType]* -- List of validated resource types :raises TypeError: If resource_type is not valid