Python interface#
Tracking Results#
from cadetrdm import ProjectRepo
"""
Your imports and function declarations
e.g. generate_data(), write_data_to_file(), analyse_data() and plot_analysis_results()
"""
if __name__ == '__main__':
# Instantiate CADET-RDM ProjectRepo handler
repo = ProjectRepo()
# If you've made changes to the code, commit the changes
repo.commit("Add code to generate and analyse example data")
# Everything written to the output_folder within this context manager gets tracked
# The method repo.output_data() generates full paths to within your output_folder
with repo.track_results(results_commit_message="Generate and analyse example data"):
data = generate_data()
write_data_to_file(data, output_folder=repo.output_folder)
analysis_results = analyse_data(data)
plot_analysis_results(analysis_results, figure_path=repo.output_folder / "analysis" / "regression.png")
Re-using results from previous iterations#
Each result stored with CADET-RDM is given a unique branch name, formatted as:
<timestamp>_<output_folder>_"from"_<active_project_branch>_<project_repo_hash[:7]>
With this branch name, previously generated data can be loaded in as input data for further calculations.
cached_folder_path = repo.input_data(branch_name=branch_name)
{
"__example/path/to/repo__": {
"source_repo_location": "git@jugit.fz-juelich.de:IBG-1/ModSim/cadet/agile_cadet_rdm_presentation_output.git",
"branch_name": "output_from_master_3910c84_2023-10-25_00-17-23",
"commit_hash": "6e3c26527999036e9490d2d86251258fe81d46dc"
}
}
Using results from another repository#
You can load in results from another repository to use in your project using the CLI:
repo.import_remote_repo(source_repo_location="<URL>", source_repo_branch="<branch_name>")
repo.import_remote_repo(source_repo_location="<URL>", source_repo_branch="<branch_name>",
target_repo_location="<path/to/where/you/want/it>")
This will store the URL, branch_name and location in the .cadet-rdm-cache.json file, like this:
{
"__example/path/to/repo__": {
"source_repo_location": "git@jugit.fz-juelich.de:IBG-1/ModSim/cadet/agile_cadet_rdm_presentation_output.git",
"branch_name": "output_from_master_3910c84_2023-10-25_00-17-23",
"commit_hash": "6e3c26527999036e9490d2d86251258fe81d46dc"
}
}
You can use this file to load the remote repositories based on the cache.json with
repo.fill_data_from_cadet_rdm_json()
Cloning from remote#
You should use cadetrdm.ProjectRepo.clone()
instead of git clone
to clone the repo to a new location.
from cadetrdm import ProjectRepo
ProjectRepo.clone("<URL><path/to/repo>")