Skip to content

Instantly share code, notes, and snippets.

@Tob-iee
Last active October 25, 2023 18:25
Show Gist options
  • Save Tob-iee/a8ce815d27d8c9eef9920a0545633314 to your computer and use it in GitHub Desktop.
Save Tob-iee/a8ce815d27d8c9eef9920a0545633314 to your computer and use it in GitHub Desktop.
Initialize a connection to Picsellia and get experiment
# Initializing picsellia connection
if 'api_token' not in os.environ:
raise Exception("You must set an api_token to run this image")
api_token = os.environ["api_token"]
if "host" not in os.environ:
host = "https://trial.picsellia.com"
else:
host = os.environ["host"]
if "organization_name " not in os.environ:
organization_name = None
else:
organization_name = os.environ["organization_name"]
client = Client(
api_token=api_token,
host=host,
organization_name=organization_name
)
# Retrieve experiment & dataset versions
if "experiment_name" in os.environ:
experiment_name = os.environ["experiment_name"]
if "project_token" in os.environ:
project_token = os.environ["project_token"]
project = client.get_project_by_id(project_token)
elif "project_name" in os.environ:
project_name = os.environ["project_name"]
project = client.get_project(project_name)
experiment = project.get_experiment(experiment_name)
else:
raise Exception("You must set the project_token or project_name and experiment_name")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment