Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine user requested specs #7

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

soapy1
Copy link
Collaborator

@soapy1 soapy1 commented Feb 18, 2025

This PR proposes a way for understanding the user requested specs in an environment. This will be different for a conda env and pixi env. This pr focuses on conda env first.

It uses conda's history class for getting the user requested specs from the environment. When the dof checkpoint is created, the user requested specs are marked and will include the conda-build/rattler compatible string representation of the MatchSpec.

Try it out

# make a check point for where we start
$ dof checkpoint save

$ dof checkpoint list                                   
                         Checkpoints                          
┏━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ uuid     ┃ tags         ┃ timestamp                        ┃
┡━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 048f93a3 │ ['048f93a3'] │ 2025-02-18 23:41:32.013738+00:00 │
└──────────┴──────────────┴──────────────────────────────────┘

# list the user requested specs in your current environment
$ dof user-specs                                                                               
the user requested specs in this environment are:
  conda
  hatch
  numpy
  pip
  pytest
  pytest-cov
  python >=3.12
  twine >=5.0.0

# install a new package 
$ conda install matplotlib

# list the user requested specs in your current environment
$ dof user-specs                                                                               
the user requested specs in this environment are:
  conda
  hatch
  matplotlib  <--- notice the new user requested spec
  numpy
  pip
  pytest
  pytest-cov
  python >=3.12
  twine >=5.0.0

# save a checkpoint
$ dof checkpoint save

$ dof checkpoint list                                   
                         Checkpoints                          
┏━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ uuid     ┃ tags         ┃ timestamp                        ┃
┡━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 16d91835 │ ['16d91835'] │ 2025-02-18 23:43:34.367435+00:00 │
│ 048f93a3 │ ['048f93a3'] │ 2025-02-18 23:41:32.013738+00:00 │
└──────────┴──────────────┴──────────────────────────────────┘

# list the user requested specs in an older environment
$ dof user-specs --rev 048f93a3                                                       
the user requested specs rev 048f93a3:
  conda
  hatch
  numpy
  pip
  pytest
  pytest-cov
  python >=3.12
  twine >=5.0.0

what about pip

The goal is to be able to fully recreate something like conda's environment.yaml. In order to do this, dof must also understand what pip packages the user has installed.
Currently, dof is able to inspect an environment and see pip installed packages. I don't expect this has enough information to make a confident guess at which packages are specifically requested by a user or not. More investigation is needed for this.

next steps

  • pip interop
  • generate an environment spec from a dof checkpoint
  • investigate how to do this for pixi envs
    • will require to do some work around allowing dof to target not currently active envs to explore this

@soapy1 soapy1 changed the title User requested specs Determine user requested specs Feb 18, 2025
@soapy1 soapy1 force-pushed the user-requested-specs branch 2 times, most recently from dd0bd89 to 86de305 Compare February 18, 2025 23:55
@soapy1 soapy1 force-pushed the user-requested-specs branch from 86de305 to 229290a Compare February 20, 2025 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant