toolsforexperiments / labcore

Collection of tools developed and maintained by Pfaff Lab
https://toolsforexperiments.github.io/labcore/
2 stars 13 forks source link

run_measurement now checks if the running directory is a git repository and commits al changes on measurement (if it is). #20

Closed marcosfrenkel closed 7 months ago

marcosfrenkel commented 9 months ago

2 Changes happening with this PR:

1: The run_measurement function now goes through all of the packages in the running environment and creates a json file with the version for each package and the commit hash if a package was installed in developer mode.

If a package has uncomitted changes, the logger will log a warning and a string saying 'uncommited-changes' will appear instead of the hash.

Question: should I simply log the warning and place the hash of the last commit? or should I make this crash and not let a measurement run unless they commit the code? Placing the hash of the commit when there are uncomitted changes feels wrong, because that is not the code that is actually running, but stopping the code from running on any change feels a little too restrictive.

2: The run_measurement function now checks if the current directory is a git repository. If it is, it will commit all present changes with a generic commit message and add the hash in the data as a json file. If the current working directory is not a git repository, it will simply log a warning.

To make this work properly we should use the example.gitignore as the gitignore file for these repositories. They will by default ignore anything except python files, jupyternotebooks, and yml and json files in the root of the repository (not in any sub-folder)

marcosfrenkel commented 7 months ago

The code has been tested in the testbed and is working