track.persistence package¶
Submodules¶
track.persistence.cockroach module¶
track.persistence.cometml module¶
track.persistence.local module¶
-
class
track.persistence.local.FileProtocol(uri, strict=True, eager=True)[source]¶ Bases:
track.persistence.protocol.ProtocolLocal File storage to manage experiments
Parameters: - uri: str
resource to use to store the experiment file://my_file.json
- strict: bool
forces the storage to be correct. if we use the file protocol as an in-memory storage we might get some inconsistencies we can use this flag to ignore them
- eager: bool
eagerly update the underlying files. This is necessary if multiple processes are reading from the file
Methods
commit(self[, file_name_override])Forces to persist the change add_group_trial add_project_trial add_trial_tags fetch_and_update_group fetch_and_update_trial fetch_groups fetch_projects fetch_trials get_project get_trial get_trial_group log_trial_arguments log_trial_chrono_finish log_trial_chrono_start log_trial_finish log_trial_metadata log_trial_metrics log_trial_start new_project new_trial new_trial_group set_group_metadata set_trial_status
-
class
track.persistence.local.LockFileRemover(filename)[source]¶ Bases:
track.utils.signal.SignalHandlerMethods
atexit remove sigint sigterm
-
track.persistence.local.execute_query(obj, query)[source]¶ Check if the object obj matches the query.
The query is a dictionary specifying constraint on each of the object attributes
-
track.persistence.local.lock_atomic_write(fun)¶
-
track.persistence.local.lock_guard(readonly, atomic=False)[source]¶ Protect a function call with a lock. reload the database before the action and save it afterwards
-
track.persistence.local.lock_read(fun)¶
-
track.persistence.local.lock_write(fun)¶
track.persistence.multiplexer module¶
-
class
track.persistence.multiplexer.ProtocolMultiplexer(*backends)[source]¶ Bases:
objectMethods
get_project(self, \*args, \*\*kwargs)add_group_trial add_project_trial add_trial_tags commit fetch_and_update_group fetch_and_update_trial fetch_groups fetch_projects fetch_trials get_trial get_trial_group log_trial_arguments log_trial_chrono_finish log_trial_chrono_start log_trial_finish log_trial_metadata log_trial_metrics log_trial_start new_project new_trial new_trial_group set_trial_status
track.persistence.protocol module¶
-
class
track.persistence.protocol.Protocol[source]¶ Bases:
objectMethods
add_group_trial(self, group, trial)Add a trial to a group add_project_trial(self, project, trial)Add a trial to a project add_trial_tags(self, trial, \*\*kwargs)Add tags to a trial commit(self, \*\*kwargs)Forces to persist the change fetch_and_update_group(self, query, attr, …)Fetch and update a single group fetch_and_update_trial(self, query, attr, …)Fetch and update a single trial fetch_groups(self, query)Fetch groups according to a given query fetch_projects(self, query)Fetch projects according to a given query fetch_trials(self, query)Fetch trials according to a given query get_project(self, project)Fetch a project according to the given definition get_trial(self, trial)Fetch trials according to a given definition get_trial_group(self, group)Fetch a group according to a given definition log_trial_arguments(self, trial, \*\*kwargs)Save the arguments a trail log_trial_chrono_finish(self, trial, name, …)Send the end signal for an event log_trial_chrono_start(self, trial, name, …)Send the start signal for an event log_trial_finish(self, trial, exc_type, …)Send the trial end signal log_trial_metadata(self, trial, aggregator, …)Save metadata for a given trials log_trial_metrics(self, trial, step, …)Save metrics for a given trials log_trial_start(self, trial)Send the trial start signal new_project(self, project)Insert a new project new_trial(self, trial[, auto_increment])Insert a new trial new_trial_group(self, group)Create a new group set_trial_status(self, trial, status[, error])Change trial status -
add_group_trial(self, group: track.structure.TrialGroup, trial: track.structure.Trial)[source]¶ Add a trial to a group
-
add_project_trial(self, project: track.structure.Project, trial: track.structure.Trial)[source]¶ Add a trial to a project
Add tags to a trial
Parameters: - trial: Trial
trial reference
- kwargs:
key value pair of the data to save
-
fetch_and_update_group(self, query, attr, *args, **kwargs)[source]¶ Fetch and update a single group
Parameters: - query: Dict
dictionary to fetch groups
- attr: str
name of the update function to call on each selected group
- *args:
additional positional arguments for the attr function
- **kwargs:
addtional keyword arguments for the attr function
Returns: - returns the modified group
-
fetch_and_update_trial(self, query, attr, *args, **kwargs)[source]¶ Fetch and update a single trial
Parameters: - query: Dict
dictionary to fetch trials
- attr: str
name of the update function to call on each selected trials
- *args:
additional positional arguments for the attr function
- **kwargs:
addtional keyword arguments for the attr function
Returns: - returns the modified trial
-
fetch_trials(self, query) → List[track.structure.Trial][source]¶ Fetch trials according to a given query
-
get_project(self, project: track.structure.Project) → Union[track.structure.Project, NoneType][source]¶ Fetch a project according to the given definition
Parameters: - project: Project
project definition used for the lookup
Returns: - returns a project object or None
-
get_trial(self, trial: track.structure.Trial) → List[track.structure.Trial][source]¶ Fetch trials according to a given definition
Parameters: - trial: Trial
trial definition used for the lookup
-
get_trial_group(self, group: track.structure.TrialGroup) → Union[track.structure.TrialGroup, NoneType][source]¶ Fetch a group according to a given definition
Parameters: - group: TrialGroup
group definition used for the lookup
Returns: - returns a grouo
-
log_trial_arguments(self, trial: track.structure.Trial, **kwargs)[source]¶ Save the arguments a trail
Parameters: - trial: Trial
trial for which the arguments are for
- kwargs:
key value pair of arguments
-
log_trial_chrono_finish(self, trial, name, exc_type, exc_val, exc_tb)[source]¶ Send the end signal for an event
Parameters: - trial: Trial
trial sending the event
- name: str
name of the event
- exc_type:
Exception object
- exec_val
Exception value
- exc_tb:
Traceback
-
log_trial_chrono_start(self, trial, name: str, aggregator: Callable[[], track.aggregators.aggregator.Aggregator] = <function StatAggregator.lazy.<locals>.<lambda> at 0x7fc3f639bf28>, start_callback=None, end_callback=None)[source]¶ Send the start signal for an event
Parameters: - trial: Trial
trial sending the event
- name: str
name of the event
- aggregator: Aggregator
container used to accumulate elapsed time
- start_callback: Callable
function called at start time
- end_callback: Callable
function called at the end
-
log_trial_finish(self, trial, exc_type, exc_val, exc_tb)[source]¶ Send the trial end signal
Parameters: - trial: Trial
reference to the trial that finished
-
log_trial_metadata(self, trial: track.structure.Trial, aggregator: Callable[[], track.aggregators.aggregator.Aggregator] = <function ValueAggregator.lazy.<locals>.<lambda> at 0x7fc3f639bd08>, **kwargs)[source]¶ Save metadata for a given trials
Parameters: - trial: Trial
trial reference
- kwargs:
key value pair of the data to save
-
log_trial_metrics(self, trial: track.structure.Trial, step: <built-in function any> = None, aggregator: Callable[[], track.aggregators.aggregator.Aggregator] = None, **kwargs)[source]¶ Save metrics for a given trials
Parameters: - trial: Trial
trial reference
- kwargs:
key value pair of the data to save
-
log_trial_start(self, trial)[source]¶ Send the trial start signal
Parameters: - trial: Trial
reference to the trial being started
-
new_project(self, project: track.structure.Project)[source]¶ Insert a new project
Parameters: - project: Project
project definition used for the insert
-
new_trial(self, trial: track.structure.Trial, auto_increment=False)[source]¶ Insert a new trial
Parameters: - trial: Trial
trial definition used for the insert
- auto_increment: bool
If trial exist increment revision number
Returns: - Returns None if Trial already exists and auto_increment is False
-
new_trial_group(self, group: track.structure.TrialGroup)[source]¶ Create a new group
Parameters: - group: TrialGroup
group definition used for the insert
-
set_trial_status(self, trial: track.structure.Trial, status, error=None)[source]¶ Change trial status
Parameters: - trial: Trial
trial reference
- status:
new status to update the trial too
- error:
in case the user is changing to a state representing an error it can also provide an error identification string
-
track.persistence.socketed module¶
- Implement a Remote Logger.
- Client forwards all the user’s request down to the server that executes them one by one.
-
class
track.persistence.socketed.ServerSignalHandler(server)[source]¶ Bases:
track.utils.signal.SignalHandlerMethods
atexit sigint sigterm
-
class
track.persistence.socketed.SocketClient(uri)[source]¶ Bases:
track.persistence.protocol.ProtocolForwards all the local track requests to the track server that execute the requests and send back the results
Clients can provide a username and password for authentication
Methods
add_group_trial(self, group, trial)Add a trial to a group add_project_trial(self, project, trial)Add a trial to a project add_trial_tags(self, trial, \*\*kwargs)Add tags to a trial authenticate(self, uri)returns the username and password used for authentication purposes you can override this function to implement a custom authentication method commit(self, \*\*kwargs)Forces to persist the change fetch_and_update_group(self, query, attr, …)Fetch and update a single group fetch_and_update_trial(self, query, attr, …)Fetch and update a single trial fetch_groups(self, query)Fetch groups according to a given query fetch_projects(self, query)Fetch projects according to a given query fetch_trials(self, query)Fetch trials according to a given query get_project(self, project)Fetch a project according to the given definition get_trial(self, trial)Fetch trials according to a given definition get_trial_group(self, group)Fetch a group according to a given definition log_trial_arguments(self, trial, \*\*kwargs)Save the arguments a trail log_trial_chrono_finish(self, trial, name, …)Send the end signal for an event log_trial_chrono_start(self, trial, name, …)Send the start signal for an event log_trial_finish(self, trial, exc_type, …)Send the trial end signal log_trial_metadata(self, trial, aggregator, …)Save metadata for a given trials log_trial_metrics(self, trial, step, …)Save metrics for a given trials log_trial_start(self, trial)Send the trial start signal new_project(self, project)Insert a new project new_trial(self, trial)Insert a new trial new_trial_group(self, group)Create a new group set_trial_status(self, trial, status[, error])Change trial status -
add_group_trial(self, group: track.structure.TrialGroup, trial: track.structure.Trial)[source]¶ Add a trial to a group
-
add_project_trial(self, project: track.structure.Project, trial: track.structure.Trial)[source]¶ Add a trial to a project
Add tags to a trial
Parameters: - trial: Trial
trial reference
- kwargs:
key value pair of the data to save
-
authenticate(self, uri)[source]¶ returns the username and password used for authentication purposes you can override this function to implement a custom authentication method
-
get_project(self, project: track.structure.Project)[source]¶ Fetch a project according to the given definition
Parameters: - project: Project
project definition used for the lookup
Returns: - returns a project object or None
-
get_trial(self, trial: track.structure.Trial)[source]¶ Fetch trials according to a given definition
Parameters: - trial: Trial
trial definition used for the lookup
-
get_trial_group(self, group: track.structure.TrialGroup)[source]¶ Fetch a group according to a given definition
Parameters: - group: TrialGroup
group definition used for the lookup
Returns: - returns a grouo
-
log_trial_arguments(self, trial: track.structure.Trial, **kwargs)[source]¶ Save the arguments a trail
Parameters: - trial: Trial
trial for which the arguments are for
- kwargs:
key value pair of arguments
-
log_trial_chrono_finish(self, trial, name, exc_type, exc_val, exc_tb)[source]¶ Send the end signal for an event
Parameters: - trial: Trial
trial sending the event
- name: str
name of the event
- exc_type:
Exception object
- exec_val
Exception value
- exc_tb:
Traceback
-
log_trial_chrono_start(self, trial, name: str, aggregator: Callable[[], track.aggregators.aggregator.Aggregator] = <function StatAggregator.lazy.<locals>.<lambda> at 0x7fc3f4102378>, start_callback=None, end_callback=None)[source]¶ Send the start signal for an event
Parameters: - trial: Trial
trial sending the event
- name: str
name of the event
- aggregator: Aggregator
container used to accumulate elapsed time
- start_callback: Callable
function called at start time
- end_callback: Callable
function called at the end
-
log_trial_finish(self, trial, exc_type, exc_val, exc_tb)[source]¶ Send the trial end signal
Parameters: - trial: Trial
reference to the trial that finished
-
log_trial_metadata(self, trial: track.structure.Trial, aggregator: Callable[[], track.aggregators.aggregator.Aggregator] = None, **kwargs)[source]¶ Save metadata for a given trials
Parameters: - trial: Trial
trial reference
- kwargs:
key value pair of the data to save
-
log_trial_metrics(self, trial: track.structure.Trial, step: <built-in function any> = None, aggregator: Callable[[], track.aggregators.aggregator.Aggregator] = None, **kwargs)[source]¶ Save metrics for a given trials
Parameters: - trial: Trial
trial reference
- kwargs:
key value pair of the data to save
-
log_trial_start(self, trial)[source]¶ Send the trial start signal
Parameters: - trial: Trial
reference to the trial being started
-
new_project(self, project: track.structure.Project)[source]¶ Insert a new project
Parameters: - project: Project
project definition used for the insert
-
new_trial(self, trial: track.structure.Trial)[source]¶ Insert a new trial
Parameters: - trial: Trial
trial definition used for the insert
- auto_increment: bool
If trial exist increment revision number
Returns: - Returns None if Trial already exists and auto_increment is False
-
new_trial_group(self, group: track.structure.TrialGroup)[source]¶ Create a new group
Parameters: - group: TrialGroup
group definition used for the insert
-
set_trial_status(self, trial: track.structure.Trial, status, error=None)[source]¶ Change trial status
Parameters: - trial: Trial
trial reference
- status:
new status to update the trial too
- error:
in case the user is changing to a state representing an error it can also provide an error identification string
-
-
class
track.persistence.socketed.SocketServer(uri)[source]¶ Bases:
track.persistence.protocol.ProtocolStart a track server inside a asyncio loop
Parameters: - uri: str
socket://{hostname}:{port}?security_layer={}&backend={protocol} with
- Users inherit this class to implement their own custom authentication
Methods
add_group_trial(self, group, trial)Add a trial to a group add_project_trial(self, project, trial)Add a trial to a project add_trial_tags(self, trial, \*\*kwargs)Add tags to a trial authenticate(self, reader, username, password)User defined authentication function commit(self, \*\*kwargs)Forces to persist the change fetch_and_update_group(self, query, attr, …)Fetch and update a single group fetch_and_update_trial(self, query, attr, …)Fetch and update a single trial fetch_groups(self, query)Fetch groups according to a given query fetch_projects(self, query)Fetch projects according to a given query fetch_trials(self, query)Fetch trials according to a given query get_project(self, project)Fetch a project according to the given definition get_trial(self, trial)Fetch trials according to a given definition get_trial_group(self, group)Fetch a group according to a given definition log_trial_arguments(self, trial, \*\*kwargs)Save the arguments a trail log_trial_chrono_finish(self, trial, name, …)Send the end signal for an event log_trial_chrono_start(self, trial, name, …)Send the start signal for an event log_trial_finish(self, trial, exc_type, …)Send the trial end signal log_trial_metadata(self, trial, aggregator, …)Save metadata for a given trials log_trial_metrics(self, trial, step, …)Save metrics for a given trials log_trial_start(self, trial)Send the trial start signal new_project(self, project)Insert a new project new_trial(self, trial[, auto_increment])Insert a new trial new_trial_group(self, group)Create a new group process_args(self, args[, cache])replace ids by their object reference so the backend modifies the objects and not a copy run_server(self)set_trial_status(self, trial, status[, error])Change trial status close close_connection exec get_username handle_client is_authenticated wait_closed -
authenticate(self, reader, username, password)[source]¶ User defined authentication function
Parameters: - reader: StreamReader
client socket / reader, can be used to link client socket -> username
- username: str
client username
- password: str
client password
-
track.persistence.socketed.start_track_server(protocol, hostname, port, security_layer=None)[source]¶ Start a track server inside a asyncio loop
Parameters: - protocol: str
URI that defines which backend to forward the request to
- hostname: str
server host name
- port: int
server port to listen to
- security_layer: str
backend used for encryption (only AES is supported)
track.persistence.storage module¶
-
class
track.persistence.storage.LocalStorage(target_file: str = None, _objects: Dict[uuid.UUID, <built-in function any>] = <factory>, _projects: Set[uuid.UUID] = <factory>, _groups: Set[uuid.UUID] = <factory>, _trials: Set[uuid.UUID] = <factory>, _project_names: Dict[str, uuid.UUID] = <factory>, _group_names: Dict[str, uuid.UUID] = <factory>, _trial_names: Dict[str, uuid.UUID] = <factory>, _old_rev_tags: Dict[str, int] = <factory>)[source]¶ Bases:
objectAttributes: - group_names
- groups
- objects
- project_names
- projects
- target_file
- trials
Methods
reload(self[, filename])Reload storage and discard current objects smart_reload(self[, filename])Updates current objects with new data commit get_current_version_tag get_previous_version_tag -
group_names¶
-
groups¶
-
objects¶
-
project_names¶
-
projects¶
-
target_file= None¶
-
trials¶