Log code¶
Comet's code logging allows you to log the code behind your Experiment.
Unless explicitly disabled, after an Experiment is created, Comet automatically logs:
- The file the the Experiment was created in.
- Relevant git information, including the git commit and the git path (i.e., uncommitted files) if they exist.
You can also log additional code from file, folder, or file-like string.
Comet allows you to search through and access code files from your Single Experiment page as well as easily compare the code used for different training runs using the experiment comparison functionality.
The git information is displayed when you want to Reproduce an Experiment.
The following method can be used to code:
log_code()
: Can be used to log both files and folders.
The code logged to an Experiment can be viewed in the following Single Experiment Tabs:
- Code Tab.
- Assets & Artifacts Tab:
notebooks
and/orsource-code
folders.
For example, you could...
Review the exact logic used for data preprocessing to ensure consistency in feature engineering across different model iterations.
Log a code file¶
The example below logs a single .py
file to Comet.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
To log a single file, you use the file_name
argument. To log a folder or a file-like object, you'd use respectively the folder
argument and the code
argument with associated code_name
.
Additionally, you could use the overwrite
argument to overwrite any existing asset with the same name.