Skip to content
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `ewoks convert`: add `--package-manager-name` and `--package-manager-command` arguments.
- Add `ewoks lint` CLI command to check if a workflow is conform to the Ewoks specification.

### Fixed

- `ewoks install` with the `pixi` package manager: no longer fails when the
default cache directory cannot be determined.

### Removed

- `ewoks install`: remove `-p/--python` argument.
Expand Down
27 changes: 27 additions & 0 deletions src/ewoks/_requirements/pixi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import platform
import re
import sys
import tempfile
from pathlib import Path
from typing import Dict
from typing import Literal
from typing import Mapping
from typing import Optional
from typing import Sequence
from typing import Union

from pydantic import Field

Expand Down Expand Up @@ -68,6 +70,20 @@ def __init__(self, *command: str) -> None:
command = ("pixi",)
super().__init__(*command)

def _check_output(
self,
*args: Union[str, Path],
extra_env: Optional[Mapping[str, Optional[str]]] = None,
) -> str:
return super()._check_output(*args, extra_env=_with_cache_dir(extra_env))

def _check_call(
self,
*args: Union[str, Path],
extra_env: Optional[Mapping[str, Optional[str]]] = None,
) -> None:
super()._check_call(*args, extra_env=_with_cache_dir(extra_env))

def version(self) -> Optional[str]:
"""Returns None when this manager is not available."""
try:
Expand Down Expand Up @@ -172,3 +188,14 @@ def _is_workspace_environment(prefix: Path) -> bool:
"""Environment is managed by a pixi workspace."""
parts = prefix.parts
return len(parts) > 2 and parts[-3] == ".pixi" and parts[-2] == "envs"


def _with_cache_dir(
extra_env: Optional[Mapping[str, Optional[str]]],
) -> Dict[str, Optional[str]]:
env = dict(extra_env) if extra_env else dict()
if not os.environ.get("PIXI_CACHE_DIR") and not os.environ.get("RATTLER_CACHE_DIR"):
env.setdefault(
"PIXI_CACHE_DIR", str(Path(tempfile.gettempdir()) / "pixi-cache")
)
return env
8 changes: 3 additions & 5 deletions src/ewoks/tests/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ def verify_notebook(tb: TestbookNotebookClient) -> None:
tb.execute()

nonlocal output_found
for output in _iter_cell_outputs(tb):
print(output)
if expected_output in output:
output_found = True
break
all_output = "".join(_iter_cell_outputs(tb))
print(all_output)
output_found = expected_output in all_output

decorator(verify_notebook)()

Expand Down
Loading