Skip to content

Commit

Permalink
Merge pull request #15 from pangeo-forge/fix-install-error-raises
Browse files Browse the repository at this point in the history
Fix install error raises
  • Loading branch information
cisaacstern authored Aug 29, 2023
2 parents 256da29 + 9b8bf34 commit f0ec71a
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Test with pytest
run: |
pytest -vvv -s --cov=action action/test_main.py
pytest -vvv -s --cov=action tests/test_main.py
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v2
30 changes: 16 additions & 14 deletions action/deploy_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import requests


def deploy_recipe_cmd(cmd: list[str]):
def call_subprocess_run(cmd: list[str]) -> str:
"""Convenience wrapper for `subprocess.run` with stdout/stderr handling."""
print(f"Calling subprocess with {cmd = }")
submit_proc = subprocess.run(cmd, capture_output=True)
stdout = submit_proc.stdout.decode()
Expand All @@ -18,12 +19,17 @@ def deploy_recipe_cmd(cmd: list[str]):
if submit_proc.returncode != 0:
for line in stderr.splitlines():
print(line)
raise ValueError("Job submission failed.")
else:
lastline = json.loads(stdout.splitlines()[-1])
job_id = lastline["job_id"]
job_name = lastline["job_name"]
print(f"Job submitted with {job_id = } and {job_name = }")
raise ValueError(f"{cmd = } failed. See logging for details.")
return stdout


def deploy_recipe_cmd(cmd: list[str]):
"""Wrapper for `call_subprocess_run` with extra stdout parsing when deploying recipes."""
stdout = call_subprocess_run(cmd)
lastline = json.loads(stdout.splitlines()[-1])
job_id = lastline["job_id"]
job_name = lastline["job_name"]
print(f"Job submitted with {job_id = } and {job_name = }")


def main():
Expand Down Expand Up @@ -83,13 +89,9 @@ def main():
# working directory is the root of the feedstock repo, so we can list feedstock repo
# contents directly on the filesystem here, without requesting it from github.
if "requirements.txt" in os.listdir(feedstock_subdir):
to_install = f"{feedstock_subdir}/requirements.txt"
print(f"Installing extra packages from {to_install}...")
install_cmd = f"mamba run -n {conda_env} pip install -Ur {to_install}".split()
install_proc = subprocess.run(install_cmd, capture_output=True, text=True)
if install_proc.returncode != 0:
# installations failed, so record the error and bail early
ValueError(f"Installs failed with {install_proc.stderr = }")
call_subprocess_run(
f"mamba run -n {conda_env} pip install -Ur {feedstock_subdir}/requirements.txt".split()
)

with tempfile.NamedTemporaryFile("w", suffix=".json") as f:
json.dump(config, f)
Expand Down
155 changes: 0 additions & 155 deletions action/test_main.py

This file was deleted.

Loading

0 comments on commit f0ec71a

Please sign in to comment.