Jacob-Stevens-Haas / mitosis

Reproduce Machine Learning experiments easily.
MIT License
3 stars 2 forks source link

ENH: Check git.Repo.is_dirty() on all editable installs #17

Open Jacob-Stevens-Haas opened 9 months ago

Jacob-Stevens-Haas commented 9 months ago

Currently, mitosis checks to see that the current working directory, if under git version control, is dirty (uncommitted changes). It also logs the commit hash of the current repo. This assumes a project organization where the experimental package and no others is installed in editable mode, because installed editable packages under setuptools_scm use the version number at the time of install.

However, there's no reason to assume that (a) mitosis is called from within the relevant git repo, and (b) no reason to assume that only one repo is installed in editable mode.

Install metadata in site-packages/.dist-info/direct-url.json includes the value {editable: True} (PEP 660/610). But since packages and installers have multiple ways of installing packages, I'm not sure how to reliably get that file without assumptions. There's been discussions back and forth about whether this will end up on packaging or importlib.metadata, but it looks like the latter. See:

CPython PR, importlib_metadata backport PR

Once the latter of those PRs is merged, I can add this feature. I don't want to add a hacky workaround just to fix it in a few months.

Jacob-Stevens-Haas commented 9 months ago

See recommendation at https://discuss.python.org/t/place-for-a-direct-url-json-parser/26266/10. I need to file a bug with setuptools

Jacob-Stevens-Haas commented 9 months ago

Bug in setuptools has a workaround - see https://github.com/pypa/setuptools/issues/4170