File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 7272 mv tmp_download_counts.json dist/download_counts.json
7373 - name : update partner resources
7474 run : python scripts/update_partner_resources.py
75+ - name : add documentation files to preview
76+ if : github.event_name == 'pull_request'
77+ run : python scripts/download_documentation.py
7578 - name : Upload preview of updated partner resources
7679 if : github.event_name == 'pull_request'
7780 uses : actions/upload-artifact@v2
Original file line number Diff line number Diff line change 1+ import warnings
2+ from pathlib import Path
3+
4+ import typer
5+
6+ from bioimageio .spec .shared import resolve_source
7+ from utils import yaml
8+
9+
10+ def main (
11+ folder : Path = Path (__file__ ).parent / "../dist" , # nested folders with rdf.yaml files
12+ ):
13+ """Download the documentation file for every rdf.yaml found in (subfolders of) folder"""
14+ if not folder .exists ():
15+ warnings .warn (f"{ folder } not found" )
16+ return
17+
18+ for rdf_path in folder .glob ("**/rdf.yaml" ):
19+ rdf = yaml .load (rdf_path )
20+ if not isinstance (rdf , dict ):
21+ warnings .warn (f"rdf not a dict: { rdf_path } " )
22+ continue
23+
24+ doc_uri = rdf .get ("documentation" )
25+ if not isinstance (doc_uri , str ):
26+ warnings .warn (f"rdf['documentation'] not a string: { rdf_path } " )
27+ continue
28+
29+ if "." in str (doc_uri ):
30+ type_ext = str (doc_uri ).split ("." )[- 1 ]
31+ else :
32+ type_ext = "md"
33+
34+ resolve_source (doc_uri , output = rdf_path .with_name (f"documentation.{ type_ext } " ))
35+
36+
37+ if __name__ == "__main__" :
38+ typer .run (main )
You can’t perform that action at this time.
0 commit comments