track package

Submodules

track.chrono module

class track.chrono.ChronoContext(acc: track.aggregators.aggregator.Aggregator, start_callback: Callable = None, end_callback: Callable = None)[source]

Bases: object

Sync is a function that can be set to make the timer wait before ending. This is useful when timing async calls like cuda calls

track.client module

class track.client.TrackClient(backend='none')[source]

Bases: object

TrackClient. A client tracks a single Trial being ran

Parameters:
backend: str

Storage backend to use

Methods

add_tags(self, \*\*kwargs) Insert tags to current trials
get_arguments(self, args, …[, show]) See log_arguments() for possible arguments
get_device() Helper function that returns a cuda device if available else a cpu
log_arguments(self, args, …[, show]) Store the arguments that was used to run the trial.
new_trial(self[, force]) Create a new trial
report(self[, short]) Print a digest of the logged metrics
save(self[, file_name_override]) Saved logged metrics into a json file
set_group(self, group, NoneType] = None, …) Set or create a new group
set_project(self, project, NoneType] = None, …) Set or create a new project
set_trial(self, trial, NoneType] = None, …) Set a new trial
set_version(self[, version]) Compute the version tag from the function call stack.
finish  
start  
add_tags(self, **kwargs)[source]

Insert tags to current trials

finish(self, exc_type=None, exc_val=None, exc_tb=None)[source]
get_arguments(self, args: Union[argparse.ArgumentParser, argparse.Namespace, Dict] = None, show=False, **kwargs) → argparse.Namespace[source]

See log_arguments() for possible arguments

static get_device()[source]

Helper function that returns a cuda device if available else a cpu

log_arguments(self, args: Union[argparse.ArgumentParser, argparse.Namespace, Dict] = None, show=False, **kwargs) → argparse.Namespace[source]

Store the arguments that was used to run the trial.

Parameters:
args: Union[ArgumentParser, Namespace, Dict]

save up the trial’s arguments

show: bool

print the arguments on the command line

kwargs

more trial’s arguments

Returns:
returns the trial’s arguments
new_trial(self, force=False, **kwargs)[source]

Create a new trial

Parameters:
force: bool

by default once the trial is set it cannot be changed. use force to override this behaviour.

kwargs:

See Trial() for possible arguments

Returns:
returns a trial logger
report(self, short=True)[source]

Print a digest of the logged metrics

save(self, file_name_override=None)[source]

Saved logged metrics into a json file

set_group(self, group: Union[track.structure.TrialGroup, NoneType] = None, force: bool = False, get_only: bool = False, **kwargs)[source]

Set or create a new group

Parameters:
group: Optional[TrialGroup]

project definition you can use to create or set the project

force: bool

by default once the trial group is set it cannot be changed. use force to override this behaviour.

get_only: bool

if true does not insert the group if missing. default to false

kwargs

arguments used to create a TrialGroup object if no TrialGroup object were provided. See TrialGroup() for possible arguments

Returns:
returns created trial group
set_project(self, project: Union[track.structure.Project, NoneType] = None, force: bool = False, get_only: bool = False, **kwargs)[source]

Set or create a new project

Parameters:
project: Optional[Project]

project definition you can use to create or set the project

force: bool

by default once the project is set it cannot be changed. use force to override this behaviour.

get_only: bool

if true does not insert the project if missing. default to false

kwargs

arguments used to create a Project object if no project object were provided See Project() for possible arguments

Returns:
returns created project
set_trial(self, trial: Union[track.structure.Trial, NoneType] = None, force: bool = False, **kwargs)[source]

Set a new trial

Parameters:
trial: Optional[Trial]

project definition you can use to create or set the project

force: bool

by default once the trial is set it cannot be changed. use force to override this behaviour.

kwargs: {uid, hash, revision}

arguments used to create a Trial object if no Trial object were provided. You should specify uid or the pair (hash, revision). See Trial() for possible arguments

Returns:
returns a trial logger
set_version(self, version=None, version_fun: Callable[[], str] = None)[source]

Compute the version tag from the function call stack. Defaults to compute the hash of the executed file

Parameters:
version: str

version string you want to use for the trial

version_fun: Callable[[], str]

version function to call to set the trial version

start(self)[source]
exception track.client.TrialDoesNotExist[source]

Bases: Exception

track.configuration module

track.configuration.find_configuration(file=None)[source]
track.configuration.options(key, default=<track.configuration._DefaultNone object at 0x7fc3f637a6a0>)[source]
track.configuration.reset_configuration()[source]

track.logger module

class track.logger.LogSignalHandler(logger)[source]

Bases: track.utils.signal.SignalHandler

Methods

atexit  
sigint  
sigterm  
atexit(self)[source]
sigint(self, signum, frame)[source]
sigterm(self, signum, frame)[source]
class track.logger.LoggerChronoContext(protocol, trial, acc=s<{'avg': 0.0, 'min': inf, 'max': -inf, 'sd': 0.0, 'count': 1, 'unit': 's'}>, name=None, **kwargs)[source]

Bases: object

class track.logger.TrialLogger(trial: track.structure.Trial, protocol: track.persistence.protocol.Protocol)[source]

Bases: object

Unified logger interface. This object should be created through the TrackClient interface

Parameters:
trial: Trial

the trial that the logger modifies

protocol: Protocol

the storage protocol used to persist the log calls

Methods

capture_output(self[, output_size]) capture standard output
chrono(self, name, aggregator, …[, …]) Start a timer to measure the time spent in that block
finish(self[, exc_type, exc_val, exc_tb]) finish trial, record end time and set the trial status to completed or interrupted
log_arguments(self, \*\*kwargs) log the trial arguments.
log_metadata(self, aggregator, …) insert metadata value inside a trial
log_metrics(self, step, aggregator, …) insert metrics values inside a trial
set_status(self, status[, error]) update trial status
start(self) Start trial, records start time and set the trial status to running
add_tags  
log_code  
log_directory  
log_file  
set_eta_total  
show_eta  
add_tags(self, **kwargs)[source]
capture_output(self, output_size=50)[source]

capture standard output

chrono(self, name: str, aggregator: Callable[[], track.aggregators.aggregator.Aggregator] = <function StatAggregator.lazy.<locals>.<lambda> at 0x7fc3f5cf6d90>, start_callback=None, end_callback=None)[source]

Start a timer to measure the time spent in that block

Parameters:
name: str

name of the timer

aggregator:

how to save the values, by default it uses the StatAggregator and only the mean, sd, max, min values are kept once the training is done

start_callback: Callable

function that is called once the timer starts

end_callback: Callable

function that is called once the timer ends

Returns:
returns a context manager that represents the timer
finish(self, exc_type=None, exc_val=None, exc_tb=None)[source]

finish trial, record end time and set the trial status to completed or interrupted

log_arguments(self, **kwargs)[source]

log the trial arguments. This function has not effect if the trial was already created.

log_code(self)[source]
log_directory(self, name, recursive=False)[source]
log_file(self, file_name)[source]
log_metadata(self, aggregator: Callable[[], track.aggregators.aggregator.Aggregator] = None, **kwargs)[source]

insert metadata value inside a trial

Parameters:
kwargs:

dictionary of metrics (metadata_name: value)

log_metrics(self, step: <built-in function any> = None, aggregator: Callable[[], track.aggregators.aggregator.Aggregator] = None, **kwargs)[source]

insert metrics values inside a trial

Parameters:
step: any

a value representing a training step (could be epoch, timestamp, …)

kwargs:

dictionary of metrics (metric_name: value)

aggregator: Optional[Callable[[], Aggregator]]

how to store the values locally

set_eta_total(self, t)[source]
set_status(self, status, error=None)[source]

update trial status

show_eta(self, step: int, timer: track.utils.stat.StatStream, msg: str = '', throttle=None, every=None, no_print=False)[source]
start(self)[source]

Start trial, records start time and set the trial status to running

track.serialization module

class track.serialization.SerializerAspect[source]

Bases: object

Methods

from_json  
to_json  
from_json(self, obj)[source]
to_json(self, obj: <built-in function any>, short=False)[source]
class track.serialization.SerializerChronoContext[source]

Bases: track.serialization.SerializerAspect

Methods

from_json  
to_json  
to_json(self, obj: <built-in function any>, short=False)[source]
class track.serialization.SerializerDatetime[source]

Bases: track.serialization.SerializerAspect

Methods

from_json  
to_json  
to_json(self, obj: datetime.datetime, short=False)[source]
class track.serialization.SerializerProject[source]

Bases: track.serialization.SerializerAspect

Methods

from_json  
to_json  
from_json(self, obj)[source]
to_json(self, obj: track.structure.Project, short=False)[source]
class track.serialization.SerializerStatStream[source]

Bases: track.serialization.SerializerAspect

Methods

from_json  
to_json  
from_json(self, obj, short=False)[source]
class track.serialization.SerializerStatus[source]

Bases: track.serialization.SerializerAspect

Methods

from_json  
to_json  
to_json(self, obj: track.structure.Status, short=False)[source]
class track.serialization.SerializerTrial[source]

Bases: track.serialization.SerializerAspect

Methods

from_json  
to_json  
from_json(self, obj)[source]
ignore_meta = {'_last_change', '_update_count', 'heartbeat'}
ignore_short = {'project_id', 'hash', 'uid', 'dtype', 'group_id'}
to_json(self, obj: track.structure.Trial, short=False)[source]
class track.serialization.SerializerTrialGroup[source]

Bases: track.serialization.SerializerAspect

Methods

from_json  
maybe_unflatten  
to_json  
from_json(self, obj)[source]
static maybe_unflatten(v)[source]
to_json(self, obj: track.structure.TrialGroup, short=False)[source]
class track.serialization.SerializerUUID[source]

Bases: track.serialization.SerializerAspect

Methods

from_json  
to_json  
to_json(self, obj: uuid.UUID, short=False)[source]
track.serialization.from_json(obj: Dict[str, <built-in function any>], dtype=None) → <built-in function any>[source]
track.serialization.to_json(k: <built-in function any>, short=False)[source]

track.structure module

hold basic data type classes that all backends need to implement

class track.structure.CustomStatus(name, value)[source]

Bases: object

Attributes:
name
value
name
value
class track.structure.Project(_uid: str = None, name: Union[str, NoneType] = None, description: Union[str, NoneType] = None, metadata: Dict[str, any] = <factory>, groups: Set[track.structure.TrialGroup] = <factory>, trials: Set[track.structure.Trial] = <factory>) → None[source]

Bases: object

Set of Trial Groups & trials If projects define tags than all children inherit those tags. children cannot override the tag of a parent

Attributes:
description
name
uid

Methods

compute_uid  
compute_uid(self) → str[source]
description = None
name = None
uid
class track.structure.Status[source]

Bases: enum.Enum

An enumeration.

Broken = 203
Completed = 302
CreatedGroup = 0
ErrorGroup = 200
Exception = 202
FinishedGroup = 300
Interrupted = 201
Running = 101
RunningGroup = 100
Suspended = 301
class track.structure.Trial(_hash: str = None, revision: int = 0, name: Union[str, NoneType] = None, description: Union[str, NoneType] = None, tags: Dict[str, any] = <factory>, version: Union[str, NoneType] = None, group_id: Union[int, NoneType] = None, project_id: Union[int, NoneType] = None, parameters: Dict[str, any] = <factory>, metadata: Dict[str, any] = <factory>, metrics: Dict[str, any] = <factory>, chronos: Dict[str, any] = <factory>, status: Union[track.structure.Status, NoneType] = <Status.CreatedGroup: 0>, errors: List[str] = <factory>) → None[source]

Bases: object

A single training run

Attributes:
description
group_id
hash
name
project_id
uid
version

Methods

compute_hash  
compute_hash(self) → str[source]
description = None
group_id = None
hash
name = None
project_id = None
revision = 0
status = 0
uid
version = None
class track.structure.TrialGroup(_uid: str = None, name: Union[str, NoneType] = None, description: Union[str, NoneType] = None, metadata: Dict[str, any] = <factory>, trials: Set[track.structure.Trial] = <factory>, project_id: Union[int, NoneType] = None) → None[source]

Bases: object

Namespace / Set of trials

Attributes:
description
name
project_id
uid

Methods

compute_uid  
compute_uid(self) → str[source]
description = None
name = None
project_id = None
uid
track.structure.get_current_project()[source]
track.structure.get_current_trial()[source]
track.structure.set_current_project(project)[source]
track.structure.set_current_trial(trial)[source]
track.structure.status(name=None, value=None)[source]

track.versioning module

track.versioning.compute_hash(*args, **kwargs)[source]
track.versioning.compute_version(files: List[str]) → str[source]
track.versioning.default_version_hash()[source]

get the current stack frames and from the file compute the version

track.versioning.get_file_version(file_name: str) → str[source]

hash the file using sha256, used in combination with get_git_version to version non committed modifications

track.versioning.get_git_version(module) → Tuple[str, str][source]
track.versioning.is_iterable(iterable)[source]

Module contents

class track.TrackClient(backend='none')[source]

Bases: object

TrackClient. A client tracks a single Trial being ran

Parameters:
backend: str

Storage backend to use

Methods

add_tags(self, \*\*kwargs) Insert tags to current trials
get_arguments(self, args, …[, show]) See log_arguments() for possible arguments
get_device() Helper function that returns a cuda device if available else a cpu
log_arguments(self, args, …[, show]) Store the arguments that was used to run the trial.
new_trial(self[, force]) Create a new trial
report(self[, short]) Print a digest of the logged metrics
save(self[, file_name_override]) Saved logged metrics into a json file
set_group(self, group, NoneType] = None, …) Set or create a new group
set_project(self, project, NoneType] = None, …) Set or create a new project
set_trial(self, trial, NoneType] = None, …) Set a new trial
set_version(self[, version]) Compute the version tag from the function call stack.
finish  
start  
add_tags(self, **kwargs)[source]

Insert tags to current trials

finish(self, exc_type=None, exc_val=None, exc_tb=None)[source]
get_arguments(self, args: Union[argparse.ArgumentParser, argparse.Namespace, Dict] = None, show=False, **kwargs) → argparse.Namespace[source]

See log_arguments() for possible arguments

static get_device()[source]

Helper function that returns a cuda device if available else a cpu

log_arguments(self, args: Union[argparse.ArgumentParser, argparse.Namespace, Dict] = None, show=False, **kwargs) → argparse.Namespace[source]

Store the arguments that was used to run the trial.

Parameters:
args: Union[ArgumentParser, Namespace, Dict]

save up the trial’s arguments

show: bool

print the arguments on the command line

kwargs

more trial’s arguments

Returns:
returns the trial’s arguments
new_trial(self, force=False, **kwargs)[source]

Create a new trial

Parameters:
force: bool

by default once the trial is set it cannot be changed. use force to override this behaviour.

kwargs:

See Trial() for possible arguments

Returns:
returns a trial logger
report(self, short=True)[source]

Print a digest of the logged metrics

save(self, file_name_override=None)[source]

Saved logged metrics into a json file

set_group(self, group: Union[track.structure.TrialGroup, NoneType] = None, force: bool = False, get_only: bool = False, **kwargs)[source]

Set or create a new group

Parameters:
group: Optional[TrialGroup]

project definition you can use to create or set the project

force: bool

by default once the trial group is set it cannot be changed. use force to override this behaviour.

get_only: bool

if true does not insert the group if missing. default to false

kwargs

arguments used to create a TrialGroup object if no TrialGroup object were provided. See TrialGroup() for possible arguments

Returns:
returns created trial group
set_project(self, project: Union[track.structure.Project, NoneType] = None, force: bool = False, get_only: bool = False, **kwargs)[source]

Set or create a new project

Parameters:
project: Optional[Project]

project definition you can use to create or set the project

force: bool

by default once the project is set it cannot be changed. use force to override this behaviour.

get_only: bool

if true does not insert the project if missing. default to false

kwargs

arguments used to create a Project object if no project object were provided See Project() for possible arguments

Returns:
returns created project
set_trial(self, trial: Union[track.structure.Trial, NoneType] = None, force: bool = False, **kwargs)[source]

Set a new trial

Parameters:
trial: Optional[Trial]

project definition you can use to create or set the project

force: bool

by default once the trial is set it cannot be changed. use force to override this behaviour.

kwargs: {uid, hash, revision}

arguments used to create a Trial object if no Trial object were provided. You should specify uid or the pair (hash, revision). See Trial() for possible arguments

Returns:
returns a trial logger
set_version(self, version=None, version_fun: Callable[[], str] = None)[source]

Compute the version tag from the function call stack. Defaults to compute the hash of the executed file

Parameters:
version: str

version string you want to use for the trial

version_fun: Callable[[], str]

version function to call to set the trial version

start(self)[source]
class track.Project(_uid: str = None, name: Union[str, NoneType] = None, description: Union[str, NoneType] = None, metadata: Dict[str, any] = <factory>, groups: Set[track.structure.TrialGroup] = <factory>, trials: Set[track.structure.Trial] = <factory>) → None[source]

Bases: object

Set of Trial Groups & trials If projects define tags than all children inherit those tags. children cannot override the tag of a parent

Attributes:
description
name
uid

Methods

compute_uid  
compute_uid(self) → str[source]
description = None
name = None
uid
class track.TrialGroup(_uid: str = None, name: Union[str, NoneType] = None, description: Union[str, NoneType] = None, metadata: Dict[str, any] = <factory>, trials: Set[track.structure.Trial] = <factory>, project_id: Union[int, NoneType] = None) → None[source]

Bases: object

Namespace / Set of trials

Attributes:
description
name
project_id
uid

Methods

compute_uid  
compute_uid(self) → str[source]
description = None
name = None
project_id = None
uid