Skip to content

maint: YAML environment specification utilities#4158

Open
jjerphan wants to merge 6 commits into
mamba-org:mainfrom
jjerphan:maint/yaml-utils
Open

maint: YAML environment specification utilities#4158
jjerphan wants to merge 6 commits into
mamba-org:mainfrom
jjerphan:maint/yaml-utils

Conversation

@jjerphan

@jjerphan jjerphan commented Feb 5, 2026

Copy link
Copy Markdown
Member

Description

Per-requisite for #4153.

Type of Change

  • Bugfix
  • Feature / enhancement
  • CI / Documentation
  • Maintenance

Checklist

  • My code follows the general style and conventions of the codebase, ensuring consistency
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run pre-commit run --all locally in the source folder and confirmed that there are no linter errors.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

@github-actions github-actions Bot added the release::maintenance For PRs related to maintenance label Feb 5, 2026
@codecov

codecov Bot commented Feb 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.36686% with 161 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.36%. Comparing base (f68450c) to head (ad702bb).

Files with missing lines Patch % Lines
micromamba/src/env.cpp 0.00% 75 Missing ⚠️
libmamba/src/api/environment_yaml.cpp 74.05% 62 Missing ⚠️
libmamba/src/api/export.cpp 0.00% 24 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4158      +/-   ##
==========================================
+ Coverage   53.93%   54.36%   +0.43%     
==========================================
  Files         240      242       +2     
  Lines       29704    32027    +2323     
  Branches     3168     3199      +31     
==========================================
+ Hits        16022    17413    +1391     
- Misses      13679    14611     +932     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jjerphan jjerphan force-pushed the maint/yaml-utils branch 6 times, most recently from 4f44235 to aae4296 Compare February 5, 2026 16:11
@jjerphan jjerphan force-pushed the maint/yaml-utils branch 2 times, most recently from 6cb440d to e1dc8a2 Compare February 23, 2026 11:52
@jjerphan jjerphan marked this pull request as ready for review February 23, 2026 12:06
@jjerphan jjerphan force-pushed the maint/yaml-utils branch 2 times, most recently from ea88ffd to 6577cdd Compare February 23, 2026 12:12

@jjerphan jjerphan left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Some points of discussions.

Comment on lines +90 to +110
try
{
const auto& channels = channel_context.make_channel(channel_str);
if (!channels.empty())
{
return channels.front().id();
}
}
catch (...)
{
// If resolution fails, try to extract channel name from URL
// e.g., "https://conda.anaconda.org/conda-forge" -> "conda-forge"
if (channel_str.find("conda.anaconda.org/") != std::string::npos)
{
auto parts = util::rsplit(channel_str, '/');
if (parts.size() >= 2)
{
return parts[parts.size() - 1];
}
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We could benefit from using expected here, but this would be yet another refactor which would impact other files.

What is the best trade-off? Should we open another PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think that would help with channel_context.make_channel as it is used everywhere as a getter for channel data and it do need to throw as any failure with that call would be a failure.
I prefer to use expected when the error is part of the algorithm, for example as return type for parsing functions (there are other examples).

What I'm not sure of is why is there a try-catch here? "resolution" isnt supposed to happen in make_channel, so I dont get the meaning of the comment in the catch.
Is that why you were thinking of using expected?

Comment on lines +148 to +155
// Helper function: Convert PackageInfo to MatchSpec string
std::string package_to_spec_string(
const specs::PackageInfo& pkg,
ChannelContext& channel_context,
bool no_builds = false,
bool ignore_channels = false,
bool include_md5 = false
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This could be a method on PackageInfo, but it is only used here and there already are similar free functions; so I am not sure that this is worth it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Are changes made to this file API breakages?

Comment thread micromamba/src/env.cpp Outdated
Comment on lines +311 to +314
catch (nlohmann::json::exception&)
{
// If parsing fails, leave variables empty
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should we warn instead here?

jjerphan added 2 commits May 4, 2026 15:36
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
@jjerphan jjerphan force-pushed the maint/yaml-utils branch from ad702bb to a6a66e4 Compare May 4, 2026 13:39
jjerphan added 4 commits May 4, 2026 15:59
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release::maintenance For PRs related to maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants