aixport package

Submodules

aixport.basecmdtool module

class aixport.basecmdtool.BaseCommandLineTool(theargs, provenance_utils=None)[source]

Bases: object

Base class for all command line tools. Command line tools MUST subclass this

Constructor

Parameters:
  • theargs (dict) – Arguments for tool. This tool expects the following values in the dict:

  • provenance_utils (ProvenanceUtil) – Wrapper for fairscape-cli which is used for RO-Crate creation and population

COMMAND = 'BaseCommandLineTool'
static add_subparser(subparsers)[source]

Should add any argparse commandline arguments to subparsers passed in This must be implemented by subclasses and will always raise an error

Parameters:

subparsers (argparse)

Raises:

AIxPORTError – will always raise this

Returns:

run()[source]

Should contain logic that will be run by command line tool. This must be implemented by subclasses and will always raise an error

Raises:

AIxPORTError – will always raise this

Returns:

aixport.benchmark module

aixport.constants module

aixport.constants.MODEL_PKL = 'model.pkl'

Name of model file using Python Pickle object structure

aixport.constants.MODEL_PREFIX = 'model'

Prefix name of file containing trained model for algorithm

aixport.constants.MODEL_PT = 'model.pt'

Name of model file using PyTorch object structure

aixport.constants.OPTIMIZETRAIN_MODE = 'optimizetrain'

Value passed to –mode or self._theargs[‘mode’] that tells model to run optimize and then train mode

aixport.constants.PREDICTIONS_DIRECTORY = 'predictions'

Name of directory where prediction results are written

aixport.constants.PREDICT_MODE = 'predict'

Value passed to –mode or self._theargs[‘mode’] that tells model to run in test/predict mode this is the same as calling TEST_MODE

aixport.constants.SUPPORTED_MODEL_FILES = ['model.pt', 'model.pkl']

All supported model file names

aixport.constants.TEST_MODE = 'test'

Value passed to –mode or self._theargs[‘mode’] that tells model to run in test/predict mode this is the same as calling PREDICT_MODE

aixport.constants.TRAINED_MODELS_DIRECTORY = 'trainedmodels'

Name of directory where trained models reside under the train RO-Crate

aixport.constants.TRAIN_MODE = 'train'

Value passed to –mode or self._theargs[‘mode’] that tells model to run in train mode

aixport.constants.TRAIN_PREDICTIONS = 'train_predictions.txt'

Name of file containing training predictions

aixport.aixportcmd module

aixport.evaluate module

class aixport.evaluate.EvaluateTool(theargs)[source]

Bases: BaseCommandLineTool

Runs benchmark pipeline

Parameters:

theargs

COMMAND = 'evaluate'
add_subparser()[source]
Returns:

run()[source]
Returns:

aixport.exceptions module

exception aixport.exceptions.AIxPORTError[source]

Bases: Exception

Base exception for AIxPORT

aixport.pipeline module

class aixport.pipeline.BenchmarkPipelineTool(theargs)[source]

Bases: BaseCommandLineTool

Runs benchmark Train step

Parameters:

theargs

COMMAND = 'benchmarkpipeline'
add_subparser()[source]
Returns:

run()[source]
Returns:

class aixport.pipeline.PredictionPipelineTool(theargs)[source]

Bases: BaseCommandLineTool

Runs benchmark Train step

Parameters:

theargs

COMMAND = 'predictpipeline'
add_subparser()[source]
Returns:

run()[source]
Returns:

aixport.predict module

class aixport.predict.AIxPORTPredictRunner(outdir=None, input_rocrates=None, trained_model_dirs=None, algorithms=None, algorithm_configs=None)[source]

Bases: object

Base runner that materializes prediction jobs.

Constructor.

run()[source]

Subclasses implement this to emit the concrete execution artifact.

class aixport.predict.BashPredictRunner(outdir=None, input_rocrates=None, trained_model_dirs=None, algorithms=None, algorithm_configs=None)[source]

Bases: AIxPORTPredictRunner

Emits bash script to run predictions serially.

Constructor.

run()[source]

Creates bash script for predictions.

class aixport.predict.PredictTool(theargs, provenance_utils=None)[source]

Bases: BaseCommandLineTool

Runs predictions using trained models.

Parameters:

theargs (dict) – arguments

COMMAND = 'predict'
add_subparser()[source]
Returns:

run()[source]
Returns:

class aixport.predict.SLURMPredictRunner(outdir=None, input_rocrates=None, trained_model_dirs=None, algorithms=None, algorithm_configs=None)[source]

Bases: AIxPORTPredictRunner

Emits SLURM scripts to run predictions on a cluster.

Constructor.

run()[source]

Creates SLURM submission script.

aixport.train module

class aixport.train.BashTrainRunner(outdir=None, input_rocrates=None, algorithms=None, algorithm_configs=None, algorithm_rocrate_configs=None)[source]

Bases: DRETrainRunner

Runs DREs via Bash script

Constructor

run()[source]
class aixport.train.DRETrainRunner(outdir=None, input_rocrates=None, algorithms=None, algorithm_configs=None, algorithm_rocrate_configs=None)[source]

Bases: object

Defines runner for invoking various Drug Recommender engines in Training mode

Constructor

run()[source]

Abstract method to run the pipeline. This method should be implemented by subclasses.

Raises:

NotImplementedError – If the subclass does not implement this method.

class aixport.train.SLURMTrainRunner(outdir=None, input_rocrates=None, algorithms=None, algorithm_configs=None, algorithm_rocrate_configs=None)[source]

Bases: DRETrainRunner

Runs DREs via SLURM

Constructor

run()[source]
class aixport.train.TrainTool(theargs, provenance_utils=None)[source]

Bases: BaseCommandLineTool

Runs benchmark pipeline

Parameters:

theargs (dict) – arguments

COMMAND = 'train'
add_subparser()[source]
Returns:

run()[source]
Returns:

aixport.rocratezipper module

class aixport.rocratezipper.ROCrateZipper(directory_path: str, zip_path: str)[source]

Bases: object

Utility for creating and inspecting ZIP archives built from RO-Crate directory trees.

Initialize with the directory to zip and the output zip file path.

Parameters:
  • directory_path – Path to the directory to compress.

  • zip_path – Path where the ZIP archive will be written.

property directory_path: str

Returns the directory path to be zipped.

extract_file(file_name: str, dest_path: str) None[source]

Extracts a specific file from the zip archive to the given destination.

list_contents() List[str][source]

Returns a list of all file names and paths inside the zip archive.

read_file(file_name: str) bytes[source]

Reads and returns the binary contents of a file inside the zip archive. Raises a FileNotFoundError if the file does not exist in the zip.

zip_directory() None[source]

Zips the entire directory (including subdirectories) into a .zip file.

property zip_path: str

Returns the target ZIP archive path.

Module contents

Top-level package for Artificial Intelligence Predictive Oncology Research Toolkit.