Skip to content

Commit 5d53ffb

Browse files
authored
Update components (#938)
* use python package to render readme * bump viash version * update dependencies
1 parent 76e280c commit 5d53ffb

7 files changed

Lines changed: 131 additions & 77 deletions

File tree

_viash.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: openproblems
22
version: dev
33
organization: openproblems-bio
4-
viash_version: 0.9.4
4+
viash_version: 0.9.7
55

66
description: |
77
Open Problems is a living, extensible, community-guided benchmarking platform.

src/project/render_readme/config.vsh.yaml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,17 @@ argument_groups:
1919
default: README.md
2020
required: false
2121
resources:
22-
- type: r_script
23-
path: script.R
22+
- type: python_script
23+
path: script.py
2424
test_resources:
25-
- type: r_script
26-
path: test.R
25+
- type: python_script
26+
path: test.py
2727
engines:
2828
- type: docker
29-
image: openproblems/base_r:1
29+
image: openproblems/base_python:1
3030
setup:
31-
- type: r
32-
cran:
33-
- processx
34-
github:
35-
- openproblems-bio/core/packages/r/openproblems.utils
36-
- openproblems-bio/core/packages/r/openproblems
37-
- openproblems-bio/core/packages/r/openproblems.docs
3831
- type: apt
39-
packages: [jq, curl]
32+
packages: [jq, curl, git]
4033
- type: docker
4134
# download and install quarto-*-linux-amd64.deb from latest release
4235
run: |

src/project/render_readme/script.R

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from pathlib import Path
2+
import subprocess
3+
4+
from openproblems.project import read_task_metadata, render_task_readme_qmd
5+
6+
## VIASH START
7+
par = {
8+
"input": "path/to/input",
9+
"output": "path/to/input/README.md",
10+
}
11+
## VIASH END
12+
13+
print("Read task metadata", flush=True)
14+
metadata = read_task_metadata(par["input"])
15+
16+
print("Render README.qmd content", flush=True)
17+
qmd_content = render_task_readme_qmd(metadata)
18+
19+
output_path = Path(par["output"])
20+
output_path.parent.mkdir(parents=True, exist_ok=True)
21+
qmd_path = output_path.with_suffix(".qmd")
22+
23+
print("Write README.qmd to file", flush=True)
24+
qmd_path.write_text(qmd_content)
25+
26+
print("Render README.qmd to README.md", flush=True)
27+
out = subprocess.run(
28+
["quarto", "render", str(qmd_path), "--output", "-"],
29+
capture_output=True,
30+
text=True,
31+
)
32+
33+
if out.returncode != 0:
34+
stdout = (out.stdout or "").strip()
35+
stderr = (out.stderr or "").strip()
36+
details = []
37+
if stdout:
38+
details.append(f"stdout:\n{stdout}")
39+
if stderr:
40+
details.append(f"stderr:\n{stderr}")
41+
if not details:
42+
details.append("No output captured from Quarto")
43+
raise RuntimeError(
44+
"Failed to render README.qmd with Quarto.\n\n" + "\n\n".join(details)
45+
)
46+
47+
output_path.write_text(out.stdout)

src/project/render_readme/test.R

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/project/render_readme/test.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import subprocess
2+
from pathlib import Path
3+
from tempfile import TemporaryDirectory
4+
5+
## VIASH START
6+
meta = {
7+
"executable": "foo",
8+
}
9+
## VIASH END
10+
11+
task_template_repo = "https://github.com/openproblems-bio/task_template.git"
12+
13+
with TemporaryDirectory() as tmpdir:
14+
tmpdir_path = Path(tmpdir)
15+
task_template_path = tmpdir_path / "task_template"
16+
input_path = task_template_path / "src" / "api"
17+
output_path = Path(tmpdir) / "README.md"
18+
qmd_path = Path(tmpdir) / "README.qmd"
19+
20+
clone_cmd = [
21+
"git",
22+
"clone",
23+
"--depth",
24+
"1",
25+
task_template_repo,
26+
str(task_template_path),
27+
]
28+
29+
print(">> Cloning task_template", flush=True)
30+
clone_out = subprocess.run(clone_cmd, capture_output=True, text=True)
31+
32+
if clone_out.stdout:
33+
print(clone_out.stdout)
34+
if clone_out.stderr:
35+
print(clone_out.stderr)
36+
37+
if clone_out.returncode:
38+
print(f"script: '{' '.join(clone_cmd)}' exited with an error.")
39+
exit(clone_out.returncode)
40+
41+
cmd = [
42+
meta["executable"],
43+
"--input",
44+
str(input_path),
45+
"--output",
46+
str(output_path),
47+
]
48+
49+
print(">> Running the script as test", flush=True)
50+
out = subprocess.run(cmd, capture_output=True, text=True)
51+
52+
if out.stdout:
53+
print(out.stdout)
54+
if out.stderr:
55+
print(out.stderr)
56+
57+
if out.returncode:
58+
print(f"script: '{' '.join(cmd)}' exited with an error.")
59+
exit(out.returncode)
60+
61+
print(">> Checking whether output files exist", flush=True)
62+
assert output_path.exists(), "README.md was not generated"
63+
assert qmd_path.exists(), "README.qmd was not generated"
64+
65+
print(">> Checking file contents", flush=True)
66+
output_lines = output_path.read_text().splitlines()
67+
qmd_lines = qmd_path.read_text().splitlines()
68+
69+
assert any("## Description" in line for line in output_lines), "README.md is missing description section"
70+
assert any("flowchart TB" in line for line in output_lines), "README.md is missing task graph"
71+
assert any("## File format:" in line for line in output_lines), "README.md is missing file format section"
72+
assert any("format: gfm" in line for line in qmd_lines), "README.qmd header is missing gfm format"
73+
74+
print("All checks succeeded!", flush=True)

src/reporting/render_report/config.vsh.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ test_resources:
4444

4545
engines:
4646
- type: docker
47-
image: openproblems/base_r:1.0.0
47+
image: openproblems/base_r:1
4848
setup:
49+
- type: apt
50+
packages: [wget]
4951
- type: docker
5052
run: |
5153
export QUARTO_VERSION="1.7.32" && \

0 commit comments

Comments
 (0)