Skip to main content

AIoD - RAIL. SDK for the RAIL service of the AI on Demand platform.

Project description

OuterRail

An SDK for AIoD - RAIL tool.

What is RAIL

RAIL stands for: Research and Innovation AI Lab

RAIL is a tool that allows AI practitioners to explore and use AI assets directly in the AI on Demand platform (AIoD). RAIL is developed within the AI4Europe project as one of the core services of the AI on Demand platform.

Requirements

Python 3.9+

Installation

pip install

The OuterRail package can simply be installed with pip via command:

pip install OuterRail

Manual installation with wheel

Usage

Importing the package

You can import the SDK with:

import OuterRail

Configuration

For the SDK to work with underlying RAIL backend, you need to specify the URL of the RAIL as well as your API key. The code for this would look something like:

import os
from OuterRail import Configuration

os.environ["AIOD_RAIL_API_KEY"] = "your_api_key"
config = Configuration(host="http://localhost:8000")

Examples:

Experiment Template Manager

### EXPERIMENT TEMPLATE MANAGER TESTING
from OuterRail import ExperimentTemplateManager

template_manager = ExperimentTemplateManager(config)

# Get the count of available templates
template_manager.count()
# Get the list of Template instances
template_manager.get()
# Get a single template by its identifier
template_manager.get_by_id("identifier_here")

# Create new template
script_path = "script.py" # Adjust this
requirements_path = "requirements.txt" # Adjust this
base_image = "python:3.9"
template_config = {
    "name": "Example Template",
    "description": "Description of example template",
    "task": "TEXT_CLASSIFICATION",
    "datasets_schema": { "cardinality": "1-1" },
    "models_schema": { "cardinality": "1-1" },
    "envs_required": [ { "name": "SPLIT_NAME", "description": "name of a subset" }
    ],
    "envs_optional": [], "available_metrics": [ "accuracy" ],
    "is_public": True
}
new_template = template_manager.create((script_path, requirements_path, base_image, template_config))

Experiment Template class

from OuterRail import ExperimentTemplateManager

# Get some experiment
template_manager = ExperimentTemplateManager(config)
template = template_manager.get()[0]

# Check if template is archived
print(template.is_archived)

# Archive template
template.archive(True)

# Update template (uses same params as create)
template.update((script_path, requirements_path, base_image, template_config)).name

# Delete template
template.delete()

Experiment Manager

from OuterRail import ExperimentManager

# Initialize
exp_manager = ExperimentManager(config)

# Get the count of experiments
exp_manager.count()
# Fetch only experiments that belong to you
experiments = exp_manager.get(mine=True)

# Create an example experiment
experiment_dict = {
    "name": "test123",
    "description": "321test",
    "is_public": True,
    "experiment_template_id": "685151f2d08da970a3a5d6ce",
    "dataset_ids": [ "data_000002AhzqHqOQwQLP0qCRds" ],
    "model_ids": [ "mdl_003Csk8QjNfE80c7g6Rt8yVb" ],
    "publication_ids": [],
    "env_vars": [ { "key": "SPLIT_NAME", "value": "Test"
        }
    ]
}
new_experiment = exp_manager.create(experiment_dict)

Experiment class

from OuterRail import ExperimentManager

# Initialize
exp_manager = ExperimentManager(config)
# Get a single experiment that belongs to you
new_experiment = exp_manager.get(mine=True)[0]

# Check archivation
new_experiment.is_archived

# Archive experiment
new_experiment.archive(archive=False)

# Update experiment
update_dict = {
    "name": "NewAndImprovedName",
    "description": "321test",
    "is_public": True,
    "experiment_template_id": "685151f2d08da970a3a5d6ce",
    "dataset_ids": [ "data_000002AhzqHqOQwQLP0qCRds" ],
    "model_ids": [ "mdl_003Csk8QjNfE80c7g6Rt8yVb" ],
    "publication_ids": [],
    "env_vars": [ { "key": "SPLIT_NAME", "value": "Test"
                    }
                  ]
}
new_experiment.update(update_dict)

# Delete
new_experiment.delete()

# Count the runs of some an experiment
new_experiment.count_runs()

# Get list of runs
new_experiment.get_runs()

Experiment run class

# Create an instance by running the experiment
exp_run = new_experiment.run()

# Check the state
print(exp_run.state)

# Check the logs of the run
print(f"exp run logs: {exp_run.logs()}")

# Delete a run
exp_run.delete()

Author

This SDK was created at KInIT by Jozef Barut.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

outerrail-1.1.0.tar.gz (85.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

outerrail-1.1.0-py3-none-any.whl (138.1 kB view details)

Uploaded Python 3

File details

Details for the file outerrail-1.1.0.tar.gz.

File metadata

  • Download URL: outerrail-1.1.0.tar.gz
  • Upload date:
  • Size: 85.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for outerrail-1.1.0.tar.gz
Algorithm Hash digest
SHA256 3d6b368cc8234331cab73f22659969431b2529b5d3cd8b68da95f17edef9cebb
MD5 d6d0b634d0aa63d856bedb1c16b89031
BLAKE2b-256 314a919d4304078080cea08346548c5eba3ba98eca1852ded09d848291efca56

See more details on using hashes here.

File details

Details for the file outerrail-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: outerrail-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 138.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for outerrail-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26f04a628a415ed1c2980bac6a06048ab038737cad27e5167a736b78a065862c
MD5 4ace11fcf14887dfe1f29b8d1aa860c2
BLAKE2b-256 3108ab8d226a0717ff75652228a54138c6ba2d1827bb71f42712ea486ff68569

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page