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

feat: allow to emit activation environment variables as JSON #1317

Merged
merged 8 commits into from
May 2, 2024

Conversation

borchero
Copy link
Contributor

@borchero borchero commented May 1, 2024

Motivation

Fixes #1298.

Changes

After talking to @pavelzw, I decided to do the following:

  • Introduce the option to emit env vars as JSON as additional flag under the shell-hook command, namely pixi shell-hook --json (in which case the choice of --shell doesn't matter)

  • Do not handle PATH in a special manner as third-party tools can still do so if required. This makes the output format maximally flexible and easily allows for augmenting it e.g. in the context of docker support: Let pixi create images #1118. The output format is now simply:

    {
      "environment_variables": {
        "<key>": "<value>"
      }
    }

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@ruben-arts ruben-arts enabled auto-merge (squash) May 2, 2024 07:37
@ruben-arts ruben-arts merged commit 8bd081b into prefix-dev:main May 2, 2024
27 checks passed
@borchero borchero deleted the json-hook branch May 2, 2024 07:58
@wolfv
Copy link
Member

wolfv commented May 2, 2024

Awesome job @borchero - there is actually one other really nice use case for this. And that's "caching" the activation. We have a way to cache a task based on the environment + inputs + outputs.

The idea would be that we hash the current environment, and store the activation variables that we generated as a JSON file. When the environment stays the same, the activation should then subsequently be much faster.

Are you perhaps interested in implementing that? :) #973

I am not sure if we should special-case the $PATH variable in that activation-cache scenario, though. And wether the current set of environment variables should be part of the hash or not.

@borchero
Copy link
Contributor Author

Sorry for the late reply @wolfv, I missed this comment before!

Sounds like a very reasonable feature, I'll have a look soonish 😁

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.

Expose activation env vars as JSON
3 participants