flip.core
FLIP Core module containing base classes and implementations.
- Exports:
FLIPBase: Abstract base class for all FLIP implementations
FLIP: Factory function for creating FLIP instances
Submodules
Classes
Abstract base class for FLIP functionality across all job types. |
Functions
|
Factory function to create appropriate FLIP instance based on job type. |
Package Contents
- class flip.core.FLIPBase[source]
Bases:
abc.ABCAbstract 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.
- logger
- abstractmethod get_dataframe(project_id: str, query: str) pandas.DataFrame[source]
Returns a dataframe for the project/query.
- abstractmethod 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 data for the given accession number.
- Parameters:
project_id (str) – The project identifier
accession_id (str) – The accession ID of the imaging study
resource_type (Union[ResourceType, List[ResourceType]]) – Type(s) of resources to download
- Returns:
Path – Path to the downloaded data
- abstractmethod add_resource(project_id: str, accession_id: str, scan_id: str, resource_id: str, files: List[str]) None[source]
Adds specific image to XNAT for an accession ID.
- abstractmethod update_status(model_id: str, new_model_status: flip.constants.flip_constants.ModelStatus) None[source]
Updates training status in Central Hub.
- Parameters:
model_id (str) – The model UUID
new_model_status (ModelStatus) – The new status to set
- abstractmethod send_metrics(client_name: str, model_id: str, label: str, value: float, round: int) None[source]
Sends a metric value to the Central Hub.
- abstractmethod send_handled_exception(formatted_exception: str, client_name: str, model_id: str) None[source]
Sends a training-related exception to Central Hub.
- abstractmethod upload_results_to_s3(results_folder: pathlib.Path, model_id: str) None[source]
Uploads results to S3 bucket.
- Parameters:
results_folder (Path) – The folder containing results to upload
model_id (str) – The model UUID for which results are being uploaded
- abstractmethod cleanup(path: pathlib.Path) None[source]
Cleans up local files.
- Parameters:
path (Path) – The path to the file or directory to clean up
- check_resource_type(resource_type: flip.constants.flip_constants.ResourceType | List[flip.constants.flip_constants.ResourceType]) List[flip.constants.flip_constants.ResourceType][source]
Check whether resource type is valid and returns them reformatted.
- Parameters:
resource_type (Union[ResourceType, List[ResourceType]]) – Single ResourceType or list of ResourceTypes
- Returns:
List[ResourceType] – List of validated resource types
- Raises:
TypeError – If resource_type is not valid
- flip.core.FLIP(job_type: flip.constants.job_types.JobType | flip.constants.job_types.JobTypeStr = JobType.STANDARD, **kwargs) flip.core.base.FLIPBase[source]
Factory function to create appropriate FLIP instance based on job type.
This is the main entry point for users to create FLIP instances. The factory automatically selects the correct implementation based on:
The job type (standard, evaluation, fed_opt, diffusion_model)
The environment (LOCAL_DEV or production)
- Parameters:
job_type – One of “standard”, “evaluation”, “fed_opt”, “diffusion_model” or a JobType enum value. Defaults to “standard”.
**kwargs – Additional arguments passed to the constructor
- Returns:
FLIPBase – Appropriate FLIP instance for the job type and environment
Examples
Create a standard FLIP instance:
flip = FLIP() df = flip.get_dataframe(project_id, query)
Create an evaluation-specific FLIP instance:
flip = FLIP(job_type="evaluation")
Use the enum-based job type:
from flip.constants import JobType flip = FLIP(job_type=JobType.DIFFUSION)