drytorch.trackers.sqlalchemy

Module containing sqlalchemy Table classes and a tracker to track metrics.

Classes

Experiment(experiment_name)

Table for experiments.

Log(source, epoch, metric_name, value)

Table for the logs of the metrics.

Run(run_id, run_ts, experiment)

Table for runs.

SQLConnection([engine])

Tracker that creates a connection to a SQL database using sqlalchemy.

Source(model_name, model_ts, source_name, ...)

Table for sources.

Tags(experiment, text)

Table for tags for experiments.

class Experiment(experiment_name)[source]

Bases: object

Table for experiments.

Parameters:

experiment_name (Mapped[str])

row_id

the unique id for the table.

Type:

sqlalchemy.orm.base.Mapped[int]

experiment_name

the experiment’s name.

Type:

sqlalchemy.orm.base.Mapped[str]

runs

the entry for the run for the experiment.

Type:

sqlalchemy.orm.base.Mapped[list[drytorch.trackers.sqlalchemy.Run]]

tags

the list of tags for the experiment.

Type:

sqlalchemy.orm.base.Mapped[list[drytorch.trackers.sqlalchemy.Tags]]

class Log(source, epoch, metric_name, value)[source]

Bases: object

Table for the logs of the metrics.

Parameters:
row_id

the unique id for the table.

Type:

sqlalchemy.orm.base.Mapped[int]

source_id

the id of the source creating the log.

Type:

sqlalchemy.orm.base.Mapped[int]

source

the entry for the source creating the log.

Type:

sqlalchemy.orm.base.Mapped[drytorch.trackers.sqlalchemy.Source]

epoch

the number of epochs the model has been trained.

Type:

sqlalchemy.orm.base.Mapped[int]

metric_name

the name of the metric.

Type:

sqlalchemy.orm.base.Mapped[str]

value

the value of the metric.

Type:

sqlalchemy.orm.base.Mapped[float]

created_at

the timestamp for the entry creation.

Type:

sqlalchemy.orm.base.Mapped[datetime.datetime]

class Run(run_id, run_ts, experiment)[source]

Bases: object

Table for runs.

A new run is created for each experiment scope, unless specified.

Parameters:
row_id

the unique id for the table.

Type:

sqlalchemy.orm.base.Mapped[int]

run_id

global identifier for the run.

Type:

sqlalchemy.orm.base.Mapped[str]

run_ts

the run’s timestamp.

Type:

sqlalchemy.orm.base.Mapped[datetime.datetime]

experiment_id

the id of the experiment for the run.

Type:

sqlalchemy.orm.base.Mapped[int]

experiment

the entry for the experiment for the run.

Type:

sqlalchemy.orm.base.Mapped[drytorch.trackers.sqlalchemy.Experiment]

sources

the list of sources from experiments

Type:

sqlalchemy.orm.base.Mapped[list[drytorch.trackers.sqlalchemy.Source]]

class SQLConnection(engine: Engine | None = None)[source]

Bases: MetricLoader

Tracker that creates a connection to a SQL database using sqlalchemy.

default_url

by default, it creates a local sqlite database.

Type:

ClassVar[sqlalchemy.engine.url.URL]

engine

the sqlalchemy Engine for the connection.

Type:

sqlalchemy.engine.base.Engine

session_factory

the Session class to initiate a sqlalchemy session.

Type:

sqlalchemy.orm.session.sessionmaker[sqlalchemy.orm.session.Session]

Initialize.

Parameters:

engine (Engine) – the engine for the session. Default uses default_url.

property run: Run

The current run.

Raises:

AccessOutsideScopeError – if there is no active run.

clean_up() None[source]

Override to clean up the tracker.

Return type:

None

notify(event: Event) None[source]
notify(event: StartExperimentEvent) None
notify(event: ActorRegistrationEvent) None
notify(event: MetricEvent) None

Notify the tracker of an event.

Parameters:

event (Event) – the event to notify about.

Return type:

None

class Source(model_name, model_ts, source_name, source_ts, run)[source]

Bases: object

Table for sources.

Parameters:
row_id

the unique id for the table.

Type:

sqlalchemy.orm.base.Mapped[int]

model_name

the model’s name.

Type:

sqlalchemy.orm.base.Mapped[str]

model_ts

the model’s timestamp.

Type:

sqlalchemy.orm.base.Mapped[datetime.datetime]

source_name

the source’s name.

Type:

sqlalchemy.orm.base.Mapped[str]

source_ts

the source’s timestamp.

Type:

sqlalchemy.orm.base.Mapped[datetime.datetime]

run_table_id

the table id for the current experiment’s run.

Type:

sqlalchemy.orm.base.Mapped[int]

run

the entry for the current experiment’s run.

Type:

sqlalchemy.orm.base.Mapped[drytorch.trackers.sqlalchemy.Run]

logs

the list of logs originating from the source.

Type:

sqlalchemy.orm.base.Mapped[list[drytorch.trackers.sqlalchemy.Log]]

class Tags(experiment, text)[source]

Bases: object

Table for tags for experiments.

Parameters:
row_id

the unique id for the table.

Type:

sqlalchemy.orm.base.Mapped[int]

experiment_id

the id for the experiment.

Type:

sqlalchemy.orm.base.Mapped[int]

text

a tag for the experiment.

Type:

sqlalchemy.orm.base.Mapped[str]