track package¶
Subpackages¶
Submodules¶
track.chrono module¶
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 argumentsget_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 Insert tags to current trials
-
get_arguments
(self, args: Union[argparse.ArgumentParser, argparse.Namespace, Dict] = None, show=False, **kwargs) → argparse.Namespace[source]¶ See
log_arguments()
for possible arguments
-
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
-
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. SeeTrialGroup()
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 SeeProject()
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). SeeTrial()
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
track.configuration module¶
track.logger module¶
-
class
track.logger.
LogSignalHandler
(logger)[source]¶ Bases:
track.utils.signal.SignalHandler
Methods
atexit sigint sigterm
-
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 -
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_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
track.serialization module¶
-
class
track.serialization.
SerializerChronoContext
[source]¶ Bases:
track.serialization.SerializerAspect
Methods
from_json to_json
-
class
track.serialization.
SerializerDatetime
[source]¶ Bases:
track.serialization.SerializerAspect
Methods
from_json to_json
-
class
track.serialization.
SerializerProject
[source]¶ Bases:
track.serialization.SerializerAspect
Methods
from_json to_json
-
class
track.serialization.
SerializerStatStream
[source]¶ Bases:
track.serialization.SerializerAspect
Methods
from_json to_json
-
class
track.serialization.
SerializerStatus
[source]¶ Bases:
track.serialization.SerializerAspect
Methods
from_json to_json
-
class
track.serialization.
SerializerTrial
[source]¶ Bases:
track.serialization.SerializerAspect
Methods
from_json to_json -
ignore_meta
= {'_last_change', '_update_count', 'heartbeat'}¶
-
ignore_short
= {'project_id', 'hash', 'uid', 'dtype', 'group_id'}¶
-
-
class
track.serialization.
SerializerTrialGroup
[source]¶ Bases:
track.serialization.SerializerAspect
Methods
from_json maybe_unflatten to_json
-
class
track.serialization.
SerializerUUID
[source]¶ Bases:
track.serialization.SerializerAspect
Methods
from_json to_json
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 -
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 -
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 -
description
= None¶
-
name
= None¶
-
project_id
= None¶
-
uid
¶
track.versioning module¶
-
track.versioning.
default_version_hash
()[source]¶ get the current stack frames and from the file compute the version
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 argumentsget_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 Insert tags to current trials
-
get_arguments
(self, args: Union[argparse.ArgumentParser, argparse.Namespace, Dict] = None, show=False, **kwargs) → argparse.Namespace[source]¶ See
log_arguments()
for possible arguments
-
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
-
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. SeeTrialGroup()
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 SeeProject()
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
-
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 -
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 -
description
= None¶
-
name
= None¶
-
project_id
= None¶
-
uid
¶