calkit-python 0.0.5__tar.gz → 0.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {calkit_python-0.0.5 → calkit_python-0.0.7}/PKG-INFO +1 -1
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/__init__.py +1 -1
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/cli.py +110 -21
- {calkit_python-0.0.5 → calkit_python-0.0.7}/.github/FUNDING.yml +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/.github/workflows/publish-test.yml +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/.github/workflows/publish.yml +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/.gitignore +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/LICENSE +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/README.md +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/cloud.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/config.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/core.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/data.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/dvc.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/git.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/gui.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/jupyter.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/models.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/server.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/tests/__init__.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/tests/test_core.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/calkit/tests/test_jupyter.py +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/examples/cfd-study/README.md +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/examples/cfd-study/calkit.yaml +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/examples/cfd-study/config/simulations/runs.csv +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/examples/cfd-study/notebook.ipynb +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/examples/ms-office/.gitignore +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/examples/ms-office/README.md +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/examples/ms-office/calkit.yaml +0 -0
- {calkit_python-0.0.5 → calkit_python-0.0.7}/pyproject.toml +0 -0
|
@@ -21,6 +21,7 @@ app = typer.Typer(
|
|
|
21
21
|
invoke_without_command=True,
|
|
22
22
|
no_args_is_help=True,
|
|
23
23
|
context_settings=dict(help_option_names=["-h", "--help"]),
|
|
24
|
+
pretty_exceptions_show_locals=False,
|
|
24
25
|
)
|
|
25
26
|
config_app = typer.Typer(no_args_is_help=True)
|
|
26
27
|
new_app = typer.Typer(no_args_is_help=True)
|
|
@@ -104,33 +105,108 @@ def get_status():
|
|
|
104
105
|
|
|
105
106
|
|
|
106
107
|
@app.command(name="add")
|
|
107
|
-
def add(
|
|
108
|
+
def add(
|
|
109
|
+
paths: list[str],
|
|
110
|
+
commit_message: Annotated[
|
|
111
|
+
str,
|
|
112
|
+
typer.Option(
|
|
113
|
+
"-m",
|
|
114
|
+
"--commit-message",
|
|
115
|
+
help="Automatically commit and use this as a message.",
|
|
116
|
+
),
|
|
117
|
+
] = None,
|
|
118
|
+
push_commit: Annotated[
|
|
119
|
+
bool, typer.Option("--push", help="Push after committing.")
|
|
120
|
+
] = False,
|
|
121
|
+
to: Annotated[
|
|
122
|
+
str,
|
|
123
|
+
typer.Option(
|
|
124
|
+
"--to", "-t", help="System with which to add (git or dvc)."
|
|
125
|
+
),
|
|
126
|
+
] = None,
|
|
127
|
+
):
|
|
108
128
|
"""Add paths to the repo.
|
|
109
129
|
|
|
110
130
|
Code will be added to Git and data will be added to DVC.
|
|
131
|
+
|
|
132
|
+
Note: This will enable the 'autostage' feature of DVC, automatically
|
|
133
|
+
adding any .dvc files to Git when adding to DVC.
|
|
111
134
|
"""
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
135
|
+
if to is not None and to not in ["git", "dvc"]:
|
|
136
|
+
typer.echo(f"Invalid option for 'to': {to}")
|
|
137
|
+
raise typer.Exit(1)
|
|
138
|
+
# Ensure autostage is enabled for DVC
|
|
139
|
+
subprocess.call(["dvc", "config", "core.autostage", "true"])
|
|
140
|
+
subprocess.call(["git", "add", ".dvc/config"])
|
|
141
|
+
if to is not None:
|
|
142
|
+
subprocess.call([to, "add"] + paths)
|
|
143
|
+
else:
|
|
144
|
+
dvc_extensions = [
|
|
145
|
+
".png",
|
|
146
|
+
".h5",
|
|
147
|
+
".parquet",
|
|
148
|
+
".pickle",
|
|
149
|
+
".mp4",
|
|
150
|
+
".avi",
|
|
151
|
+
".webm",
|
|
152
|
+
".pdf",
|
|
153
|
+
]
|
|
154
|
+
dvc_size_thresh_bytes = 1_000_000
|
|
155
|
+
if "." in paths and to is None:
|
|
156
|
+
typer.echo("Cannot add '.' with calkit; use git or dvc")
|
|
157
|
+
raise typer.Exit(1)
|
|
158
|
+
if to is None:
|
|
159
|
+
for path in paths:
|
|
160
|
+
if os.path.isdir(path):
|
|
161
|
+
typer.echo("Cannot auto-add directories; use git or dvc")
|
|
162
|
+
raise typer.Exit(1)
|
|
163
|
+
for path in paths:
|
|
164
|
+
# Detect if this file should be tracked with Git or DVC
|
|
165
|
+
if os.path.splitext(path)[-1] in dvc_extensions:
|
|
166
|
+
typer.echo(f"Adding {path} to DVC per its extension")
|
|
167
|
+
subprocess.call(["dvc", "add", path])
|
|
168
|
+
continue
|
|
169
|
+
if os.path.getsize(path) > dvc_size_thresh_bytes:
|
|
170
|
+
typer.echo(
|
|
171
|
+
f"Adding {path} to DVC since it's greater than 1 MB"
|
|
172
|
+
)
|
|
173
|
+
subprocess.call(["dvc", "add", path])
|
|
174
|
+
continue
|
|
175
|
+
typer.echo(f"Adding {path} to Git")
|
|
176
|
+
subprocess.call(["git", "add", path])
|
|
177
|
+
if commit_message is not None:
|
|
178
|
+
subprocess.call(["git", "commit", "-m", commit_message])
|
|
179
|
+
if push_commit:
|
|
180
|
+
push()
|
|
124
181
|
|
|
125
182
|
|
|
126
183
|
@app.command(name="commit")
|
|
127
184
|
def commit(
|
|
128
|
-
all: Annotated[
|
|
129
|
-
|
|
185
|
+
all: Annotated[
|
|
186
|
+
Optional[bool],
|
|
187
|
+
typer.Option(
|
|
188
|
+
"--all", "-a", help="Automatically stage all changed files."
|
|
189
|
+
),
|
|
190
|
+
] = False,
|
|
191
|
+
message: Annotated[
|
|
192
|
+
Optional[str], typer.Option("--message", "-m", help="Commit message.")
|
|
193
|
+
] = None,
|
|
194
|
+
push_commit: Annotated[
|
|
195
|
+
bool,
|
|
196
|
+
typer.Option(
|
|
197
|
+
"--push", help="Push to both Git and DVC after committing."
|
|
198
|
+
),
|
|
199
|
+
] = False,
|
|
130
200
|
):
|
|
131
201
|
"""Commit a change to the repo."""
|
|
132
|
-
|
|
133
|
-
|
|
202
|
+
cmd = ["git", "commit"]
|
|
203
|
+
if all:
|
|
204
|
+
cmd.append("-a")
|
|
205
|
+
if message:
|
|
206
|
+
cmd += ["-m", message]
|
|
207
|
+
subprocess.call(cmd)
|
|
208
|
+
if push_commit:
|
|
209
|
+
push()
|
|
134
210
|
|
|
135
211
|
|
|
136
212
|
@app.command(name="pull", help="Pull with both Git and DVC.")
|
|
@@ -270,15 +346,28 @@ def clean_notebook_outputs(path: str):
|
|
|
270
346
|
|
|
271
347
|
|
|
272
348
|
@notebooks_app.command("execute")
|
|
273
|
-
def execute_notebook(
|
|
274
|
-
|
|
349
|
+
def execute_notebook(
|
|
350
|
+
path: str,
|
|
351
|
+
to: Annotated[
|
|
352
|
+
str, typer.Option("--to", help="Output format ('html' or 'notebook').")
|
|
353
|
+
] = "notebook",
|
|
354
|
+
):
|
|
355
|
+
"""Execute notebook and place a copy in the relevant directory.
|
|
275
356
|
|
|
276
357
|
This can be useful to use as a preprocessing DVC stage to use a clean
|
|
277
358
|
notebook as a dependency for a stage that caches and executed notebook.
|
|
278
359
|
"""
|
|
279
360
|
if os.path.isabs(path):
|
|
280
361
|
raise ValueError("Path must be relative")
|
|
281
|
-
|
|
362
|
+
if to == "html":
|
|
363
|
+
subdir = "html"
|
|
364
|
+
fname_out = path.removesuffix(".ipynb") + ".html"
|
|
365
|
+
elif to == "notebook":
|
|
366
|
+
subdir = "executed"
|
|
367
|
+
fname_out = path
|
|
368
|
+
else:
|
|
369
|
+
raise ValueError(f"Invalid output format: '{to}'")
|
|
370
|
+
fpath_out = os.path.join(".calkit", "notebooks", subdir, fname_out)
|
|
282
371
|
folder = os.path.dirname(fpath_out)
|
|
283
372
|
os.makedirs(folder, exist_ok=True)
|
|
284
373
|
subprocess.call(
|
|
@@ -288,7 +377,7 @@ def execute_notebook(path: str):
|
|
|
288
377
|
path,
|
|
289
378
|
"--execute",
|
|
290
379
|
"--to",
|
|
291
|
-
|
|
380
|
+
to,
|
|
292
381
|
"--output",
|
|
293
382
|
fpath_out,
|
|
294
383
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|