2023-10-02 17:43:44 +00:00
|
|
|
# ClearML - example code for logging configuration files to Task":
|
|
|
|
#
|
|
|
|
import json
|
|
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
from clearml import Task
|
|
|
|
|
|
|
|
|
|
|
|
# Connecting ClearML with the current process,
|
|
|
|
# from here on everything is logged automatically
|
|
|
|
task = Task.init(project_name='FirstTrial', task_name='config_files_example')
|
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------
|
|
|
|
# Log config file
|
|
|
|
# Notice any file format i supported
|
|
|
|
# In the Web UI you could edit the configuration file directly as text
|
|
|
|
# and launch on a remote worker with the new configuration automatically applied
|
|
|
|
# -----------------------------------------------
|
|
|
|
|
|
|
|
config_file = task.connect_configuration(Path("data_samples") / "sample.json", name='json config file')
|
|
|
|
|
2023-11-05 19:00:04 +00:00
|
|
|
with open(config_file.as_posix(), "rt") as f:
|
2023-10-02 17:43:44 +00:00
|
|
|
config_json = json.load(f)
|
|
|
|
|
|
|
|
print(config_json)
|
|
|
|
|
|
|
|
config_file = task.connect_configuration(Path("data_samples") / "config_yaml.yaml", name='yaml config file')
|
|
|
|
|
2023-11-05 19:00:04 +00:00
|
|
|
with open(config_file.as_posix(), "rt") as f:
|
2023-10-02 17:43:44 +00:00
|
|
|
config_yaml = yaml.load(f, Loader=yaml.SafeLoader)
|
|
|
|
|
|
|
|
print(config_yaml)
|
|
|
|
|
|
|
|
print("done")
|