Skip to content

Conversation

soapy1
Copy link
Contributor

@soapy1 soapy1 commented Jul 9, 2025

Description

Iterable values coming from the context objects are usually returned as tuples. This PR changes the EnvironmentConfig types to more closely match the context.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@soapy1 soapy1 force-pushed the ensure-environment-config-has-right-types branch from 2d678f7 to df8a2a5 Compare July 9, 2025 19:44
@soapy1 soapy1 force-pushed the ensure-environment-config-has-right-types branch from df8a2a5 to 1515745 Compare July 9, 2025 19:45
@github-project-automation github-project-automation bot moved this to 🆕 New in 🔎 Review Jul 9, 2025
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Jul 9, 2025
Copy link

codspeed-hq bot commented Jul 9, 2025

CodSpeed Instrumentation Performance Report

Merging #15000 will not alter performance

Comparing soapy1:ensure-environment-config-has-right-types (ee1d394) with main (b4b0e8d)

Summary

✅ 21 untouched benchmarks

@soapy1 soapy1 marked this pull request as ready for review July 10, 2025 01:37
@soapy1 soapy1 requested a review from a team as a code owner July 10, 2025 01:37
@soapy1
Copy link
Contributor Author

soapy1 commented Jul 10, 2025

pre-commit.ci autofix

@soapy1 soapy1 changed the title Ensure all tuple values from context are transformed into a list in the EnvironmentConfig EnvironmentConfig lists of values should be tuples Jul 10, 2025
@soapy1 soapy1 force-pushed the ensure-environment-config-has-right-types branch from 7a11815 to 2530e1c Compare July 10, 2025 17:12
@soapy1
Copy link
Contributor Author

soapy1 commented Jul 10, 2025

pre-commit.ci autofix

@soapy1 soapy1 force-pushed the ensure-environment-config-has-right-types branch from 61c274f to ee1d394 Compare July 10, 2025 17:51
@soapy1 soapy1 requested a review from jaimergp July 10, 2025 18:23
@peytondmurray
Copy link
Contributor

peytondmurray commented Jul 10, 2025

This is a nice improvement, thanks! I double checked the field types of the EnvironmentConfig and compared them to corresponding attributes of the context object in my local dev environment, and they (nearly) line up at this point:

                    field_name              field_type        context_field_type
0   aggressive_update_packages              tuple[str]           <class 'tuple'>
1             channel_priority  ChannelPriority | None  <enum 'ChannelPriority'>
2                     channels              tuple[str]           <class 'tuple'>
3             channel_settings   tuple[dict[str, str]]           <class 'tuple'>
4                deps_modifier     DepsModifier | None     <enum 'DepsModifier'>
5          disallowed_packages              tuple[str]           <class 'tuple'>
6              pinned_packages              tuple[str]           <class 'tuple'>
7                 repodata_fns              tuple[str]           <class 'tuple'>
8                   sat_solver  SatSolverChoice | None  <enum 'SatSolverChoice'>
9                       solver              str | None             <class 'str'>
10              track_features              tuple[str]           <class 'tuple'>
11             update_modifier   UpdateModifier | None   <enum 'UpdateModifier'>
12            use_only_tar_bz2             bool | None        <class 'NoneType'>

There are a few remaining incompatibilities, for example the enum types in the context do not support None as a valid setting, but maybe that's best handled in a separate issue, or maybe not at all? I guess it depends on what purpose the EnvironmentConfig is really supposed to serve, and what role if any the context has in relation to it.

@soapy1
Copy link
Contributor Author

soapy1 commented Jul 11, 2025

Nice @peytondmurray, thanks this is really helpful!

for example the enum types in the context do not support None as a valid setting,

I think in this case it's ok for EnvironmentConfig to be different from the context. For example, if these enum values can not be None in the EnvironmentConfig then they need to always be populated with something valid. This can either be (1) the default value for the config, or (2) a null value.

The EnvironmentConfig object is meant to be created by environment spec plugins. It's valid for an environment spec to not support all the possible environment config fields. In this case, I think these plugin authors shouldn't have the responsibility of choosing good defaults for these pieces of config that they don't want to control. It's maybe best for default values to always be coming from the same source. In this case, the context object is a good source of truth for good default values.

Definitely open to looking at this another way!

@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Approved in 🔎 Review Jul 11, 2025
@jezdez jezdez merged commit 85832cc into conda:main Jul 14, 2025
75 checks passed
@github-project-automation github-project-automation bot moved this from ✅ Approved to 🏁 Done in 🔎 Review Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants