Skip to content

Commit 5514a4b

Browse files
committed
Adds per-tutorial downloads via gh-pages index
1 parent 229d3dd commit 5514a4b

File tree

6 files changed

+448
-196
lines changed

6 files changed

+448
-196
lines changed

src/easydiffraction/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
from easydiffraction.utils.logging import Logger
88
from easydiffraction.utils.logging import console
99
from easydiffraction.utils.logging import log
10+
from easydiffraction.utils.utils import download_all_tutorials
1011
from easydiffraction.utils.utils import download_data
11-
from easydiffraction.utils.utils import fetch_tutorials
12+
from easydiffraction.utils.utils import download_tutorial
1213
from easydiffraction.utils.utils import get_value_from_xye_header
1314
from easydiffraction.utils.utils import list_tutorials
1415
from easydiffraction.utils.utils import show_version
@@ -18,7 +19,8 @@
1819
'ExperimentFactory',
1920
'SampleModelFactory',
2021
'download_data',
21-
'fetch_tutorials',
22+
'download_tutorial',
23+
'download_all_tutorials',
2224
'list_tutorials',
2325
'get_value_from_xye_header',
2426
'show_version',

src/easydiffraction/__main__.py

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,43 @@ def list_tutorials():
4343
ed.list_tutorials()
4444

4545

46-
@app.command('fetch-tutorials')
47-
def fetch_tutorials():
48-
"""Download and extract tutorial notebooks."""
49-
ed.fetch_tutorials()
46+
@app.command('download-tutorial')
47+
def download_tutorial(
48+
id: int = typer.Argument(..., help='Tutorial ID to download.'),
49+
destination: str = typer.Option(
50+
'tutorials',
51+
'--destination',
52+
'-d',
53+
help='Directory to save the tutorial into.',
54+
),
55+
overwrite: bool = typer.Option(
56+
False, # noqa: FBT003 - boolean option is intended
57+
'--overwrite',
58+
'-o',
59+
help='Overwrite existing file if present.',
60+
),
61+
):
62+
"""Download a specific tutorial notebook by ID."""
63+
ed.download_tutorial(id=id, destination=destination, overwrite=overwrite)
64+
65+
66+
@app.command('download-all-tutorials')
67+
def download_all_tutorials(
68+
destination: str = typer.Option(
69+
'tutorials',
70+
'--destination',
71+
'-d',
72+
help='Directory to save the tutorials into.',
73+
),
74+
overwrite: bool = typer.Option(
75+
False, # noqa: FBT003 - boolean option is intended
76+
'--overwrite',
77+
'-o',
78+
help='Overwrite existing files if present.',
79+
),
80+
):
81+
"""Download all available tutorial notebooks."""
82+
ed.download_all_tutorials(destination=destination, overwrite=overwrite)
5083

5184

5285
if __name__ == '__main__':

0 commit comments

Comments
 (0)