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

Use mamba env export with --json #2162

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ repos:
"requests",
"urllib3",
"types-beautifulsoup4",
"types-PyYAML",
"types-requests",
"types-tabulate",
"types-urllib3",
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ pytest-retry
# `pytest-xdist` is a plugin that provides the `--numprocesses` flag,
# allowing us to run `pytest` tests in parallel
pytest-xdist
PyYAML
requests
tabulate
6 changes: 3 additions & 3 deletions tests/package_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import json
import logging
import re
from collections import defaultdict
from itertools import chain
from typing import Any, Optional

import yaml
from docker.models.containers import Container
from tabulate import tabulate

Expand Down Expand Up @@ -61,7 +61,7 @@ def start_container(container: TrackedContainer) -> Container:
@staticmethod
def _conda_export_command(from_history: bool) -> list[str]:
"""Return the mamba export command with or without history"""
cmd = ["mamba", "env", "export", "--no-build"]
cmd = ["mamba", "env", "export", "--no-build", "--json"]
if from_history:
cmd.append("--from-history")
return cmd
Expand Down Expand Up @@ -96,7 +96,7 @@ def _execute_command(self, command: list[str]) -> str:
@staticmethod
def _parse_package_versions(env_export: str) -> dict[str, set[str]]:
"""Extract packages and versions from the lines returned by the list of specifications"""
dependencies = yaml.safe_load(env_export).get("dependencies")
dependencies = json.loads(env_export).get("dependencies")
# Filtering packages installed through pip
# since we only manage packages installed through mamba here
# They are represented by a dict with a key 'pip'
Expand Down