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
2 changes: 1 addition & 1 deletion _viash.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: openproblems
version: dev
organization: openproblems-bio
viash_version: 0.9.4
viash_version: 0.9.7

description: |
Open Problems is a living, extensible, community-guided benchmarking platform.
Expand Down
19 changes: 6 additions & 13 deletions src/project/render_readme/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,17 @@ argument_groups:
default: README.md
required: false
resources:
- type: r_script
path: script.R
- type: python_script
path: script.py
test_resources:
- type: r_script
path: test.R
- type: python_script
path: test.py
engines:
- type: docker
image: openproblems/base_r:1
image: openproblems/base_python:1
setup:
- type: r
cran:
- processx
github:
- openproblems-bio/core/packages/r/openproblems.utils
- openproblems-bio/core/packages/r/openproblems
- openproblems-bio/core/packages/r/openproblems.docs
- type: apt
packages: [jq, curl]
packages: [jq, curl, git]
- type: docker
# download and install quarto-*-linux-amd64.deb from latest release
run: |
Expand Down
35 changes: 0 additions & 35 deletions src/project/render_readme/script.R

This file was deleted.

47 changes: 47 additions & 0 deletions src/project/render_readme/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from pathlib import Path
import subprocess

from openproblems.project import read_task_metadata, render_task_readme_qmd

## VIASH START
par = {
"input": "path/to/input",
"output": "path/to/input/README.md",
}
## VIASH END

print("Read task metadata", flush=True)
metadata = read_task_metadata(par["input"])

print("Render README.qmd content", flush=True)
qmd_content = render_task_readme_qmd(metadata)

output_path = Path(par["output"])
output_path.parent.mkdir(parents=True, exist_ok=True)
qmd_path = output_path.with_suffix(".qmd")

print("Write README.qmd to file", flush=True)
qmd_path.write_text(qmd_content)

print("Render README.qmd to README.md", flush=True)
out = subprocess.run(
["quarto", "render", str(qmd_path), "--output", "-"],
capture_output=True,
text=True,
)

if out.returncode != 0:
stdout = (out.stdout or "").strip()
stderr = (out.stderr or "").strip()
details = []
if stdout:
details.append(f"stdout:\n{stdout}")
if stderr:
details.append(f"stderr:\n{stderr}")
if not details:
details.append("No output captured from Quarto")
raise RuntimeError(
"Failed to render README.qmd with Quarto.\n\n" + "\n\n".join(details)
)

output_path.write_text(out.stdout)
27 changes: 0 additions & 27 deletions src/project/render_readme/test.R

This file was deleted.

74 changes: 74 additions & 0 deletions src/project/render_readme/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import subprocess
from pathlib import Path
from tempfile import TemporaryDirectory

## VIASH START
meta = {
"executable": "foo",
}
## VIASH END

task_template_repo = "https://github.com/openproblems-bio/task_template.git"

with TemporaryDirectory() as tmpdir:
tmpdir_path = Path(tmpdir)
task_template_path = tmpdir_path / "task_template"
input_path = task_template_path / "src" / "api"
output_path = Path(tmpdir) / "README.md"
qmd_path = Path(tmpdir) / "README.qmd"

clone_cmd = [
"git",
"clone",
"--depth",
"1",
task_template_repo,
str(task_template_path),
]

print(">> Cloning task_template", flush=True)
clone_out = subprocess.run(clone_cmd, capture_output=True, text=True)

if clone_out.stdout:
print(clone_out.stdout)
if clone_out.stderr:
print(clone_out.stderr)

if clone_out.returncode:
print(f"script: '{' '.join(clone_cmd)}' exited with an error.")
exit(clone_out.returncode)

cmd = [
meta["executable"],
"--input",
str(input_path),
"--output",
str(output_path),
]

print(">> Running the script as test", flush=True)
out = subprocess.run(cmd, capture_output=True, text=True)

if out.stdout:
print(out.stdout)
if out.stderr:
print(out.stderr)

if out.returncode:
print(f"script: '{' '.join(cmd)}' exited with an error.")
exit(out.returncode)

print(">> Checking whether output files exist", flush=True)
assert output_path.exists(), "README.md was not generated"
assert qmd_path.exists(), "README.qmd was not generated"

print(">> Checking file contents", flush=True)
output_lines = output_path.read_text().splitlines()
qmd_lines = qmd_path.read_text().splitlines()

assert any("## Description" in line for line in output_lines), "README.md is missing description section"
assert any("flowchart TB" in line for line in output_lines), "README.md is missing task graph"
assert any("## File format:" in line for line in output_lines), "README.md is missing file format section"
assert any("format: gfm" in line for line in qmd_lines), "README.qmd header is missing gfm format"

print("All checks succeeded!", flush=True)
4 changes: 3 additions & 1 deletion src/reporting/render_report/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ test_resources:

engines:
- type: docker
image: openproblems/base_r:1.0.0
image: openproblems/base_r:1
setup:
- type: apt
packages: [wget]
- type: docker
run: |
export QUARTO_VERSION="1.7.32" && \
Expand Down
Loading