Skip to content

Commit

Permalink
runner.conda: Hint in check-setup output if setup conda needs to be…
Browse files Browse the repository at this point in the history
… run

The Conda runner is the first that can be setup all by itself, as long
as the OS is supported.  The current design of check-setup doesn't
really account for the separate state of supported vs. set up, so I
conditionalize what we report from test_setup().

As we add more automatic setup support for runtimes¹, it will probably
be good to change check-setup to consider support status and set up
status separately.

¹ e.g. <#220>
  • Loading branch information
tsibley committed Jan 13, 2023
1 parent 645afc2 commit 81abd82
Showing 1 changed file with 45 additions and 24 deletions.
69 changes: 45 additions & 24 deletions nextstrain/cli/runner/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from ..errors import InternalError
from ..paths import RUNTIMES
from ..types import RunnerSetupStatus, RunnerTestResults, RunnerUpdateStatus
from ..util import capture_output, exec_or_return, warn
from ..util import capture_output, exec_or_return, runner_tests_ok, warn


RUNTIME_ROOT = RUNTIMES / "conda/"
Expand Down Expand Up @@ -351,24 +351,6 @@ def micromamba(*args, add_prefix: bool = True) -> None:


def test_setup() -> RunnerTestResults:
def supported_os() -> bool:
machine = platform.machine()
system = platform.system()

if system == "Linux":
return machine == "x86_64"

# Note even on arm64 (e.g. aarch64, Apple Silicon M1) we use x86_64
# binaries because of current ecosystem compatibility, but Rosetta will
# make it work.
elif system == "Darwin":
return machine in {"x86_64", "arm64"}

# Conda supports Windows, but we can't because several programs we need
# are not available for Windows.
else:
return False

def which_finds_our(cmd) -> bool:
# which() checks executability and also handles PATHEXT, e.g. the
# ".exe" extension on Windows, which is why we don't just naively test
Expand Down Expand Up @@ -397,12 +379,22 @@ def runnable(*argv) -> bool:
return False


return [
('operating system is supported',
supported_os()),
support = test_support()

("runtime data dir doesn't have spaces",
" " not in str(RUNTIME_ROOT)),
if not runner_tests_ok(support):
return support

if not PREFIX_BIN.exists():
return [
*support,
("runtime appears set up\n\n"
"The Conda runtime appears supported but not yet set up.\n"
"Try running `nextstrain setup conda` first.", False),
]

return [
*support,
("runtime appears set up", True),

('snakemake is installed and runnable',
which_finds_our("snakemake") and runnable("snakemake", "--version")),
Expand All @@ -415,6 +407,35 @@ def runnable(*argv) -> bool:
]


def test_support() -> RunnerTestResults:
def supported_os() -> bool:
machine = platform.machine()
system = platform.system()

if system == "Linux":
return machine == "x86_64"

# Note even on arm64 (e.g. aarch64, Apple Silicon M1) we use x86_64
# binaries because of current ecosystem compatibility, but Rosetta will
# make it work.
elif system == "Darwin":
return machine in {"x86_64", "arm64"}

# Conda supports Windows, but we can't because several programs we need
# are not available for Windows.
else:
return False


return [
('operating system is supported',
supported_os()),

("runtime data dir doesn't have spaces",
" " not in str(RUNTIME_ROOT)),
]


def set_default_config() -> None:
"""
No-op.
Expand Down

0 comments on commit 81abd82

Please sign in to comment.