calkit-python 0.3.0__tar.gz → 0.3.1__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.3.0 → calkit_python-0.3.1}/PKG-INFO +1 -1
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/__init__.py +1 -1
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/cli/office.py +14 -2
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/git.py +4 -1
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/models.py +5 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/office.py +4 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/server.py +30 -10
- {calkit_python-0.3.0 → calkit_python-0.3.1}/.github/FUNDING.yml +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/.github/workflows/publish-test.yml +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/.github/workflows/publish.yml +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/.gitignore +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/LICENSE +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/README.md +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/cli/__init__.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/cli/config.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/cli/core.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/cli/import_.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/cli/list.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/cli/main.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/cli/new.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/cli/notebooks.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/cloud.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/config.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/core.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/data.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/docker.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/dvc.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/gui.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/jupyter.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/tests/__init__.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/tests/cli/__init__.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/tests/cli/test_list.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/tests/cli/test_main.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/tests/cli/test_new.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/tests/test_core.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/tests/test_dvc.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/calkit/tests/test_jupyter.py +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/examples/cfd-study/README.md +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/examples/cfd-study/calkit.yaml +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/examples/cfd-study/config/simulations/runs.csv +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/examples/cfd-study/notebook.ipynb +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/examples/ms-office/.gitignore +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/examples/ms-office/README.md +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/examples/ms-office/calkit.yaml +0 -0
- {calkit_python-0.3.0 → calkit_python-0.3.1}/pyproject.toml +0 -0
|
@@ -44,7 +44,19 @@ def excel_chart_to_png(
|
|
|
44
44
|
|
|
45
45
|
@office_app.command(name="word-to-pdf", help="Convert a Word document to PDF.")
|
|
46
46
|
def word_to_pdf(
|
|
47
|
-
input_fpath: Annotated[
|
|
48
|
-
|
|
47
|
+
input_fpath: Annotated[
|
|
48
|
+
str, typer.Argument(help="Input Word document file path.")
|
|
49
|
+
],
|
|
50
|
+
output_fpath: Annotated[
|
|
51
|
+
str,
|
|
52
|
+
typer.Option(
|
|
53
|
+
"-o",
|
|
54
|
+
"--output",
|
|
55
|
+
help=(
|
|
56
|
+
"Output file path. If not specified, "
|
|
57
|
+
"will be the same as input with a .pdf extension."
|
|
58
|
+
),
|
|
59
|
+
),
|
|
60
|
+
] = None,
|
|
49
61
|
):
|
|
50
62
|
docx2pdf.convert(input_path=input_fpath, output_path=output_fpath)
|
|
@@ -8,7 +8,10 @@ import git
|
|
|
8
8
|
def detect_project_name(path=None) -> str:
|
|
9
9
|
"""Read the project owner and name from the remote.
|
|
10
10
|
|
|
11
|
-
TODO: Currently only works with GitHub remotes
|
|
11
|
+
TODO: Currently only works with GitHub remotes where the GitHub repo
|
|
12
|
+
name is identical to the Calkit project name, which is not guaranteed.
|
|
13
|
+
We should probably look inside ``calkit.yaml`` at ``name``
|
|
14
|
+
first, and fallback to the GitHub remote URL if we can't find that.
|
|
12
15
|
"""
|
|
13
16
|
url = git.Repo(path=path).remote().url
|
|
14
17
|
return url.split("github.com")[-1][1:].removesuffix(".git")
|
|
@@ -107,6 +107,11 @@ class ProjectInfo(BaseModel):
|
|
|
107
107
|
distinguish what has been newly created here.
|
|
108
108
|
"""
|
|
109
109
|
|
|
110
|
+
title: str | None = None
|
|
111
|
+
owner: str | None = None
|
|
112
|
+
description: str | None = None
|
|
113
|
+
name: str | None = None
|
|
114
|
+
git_repo_url: str | None = None
|
|
110
115
|
parent: str | None = None
|
|
111
116
|
questions: list[str] = []
|
|
112
117
|
datasets: list[Dataset] = []
|
|
@@ -23,6 +23,7 @@ def excel_chart_to_png(
|
|
|
23
23
|
wb = excel.Workbooks.Open(os.path.abspath(input_fpath))
|
|
24
24
|
factor = 1.0
|
|
25
25
|
# Extract sheet
|
|
26
|
+
# TODO: Close workbook if something fails
|
|
26
27
|
sheet = excel.Sheets(sheet)
|
|
27
28
|
shape = sheet.Shapes[chart_index]
|
|
28
29
|
shape.Copy()
|
|
@@ -31,6 +32,9 @@ def excel_chart_to_png(
|
|
|
31
32
|
size = int(factor * length_x), int(factor * width_y)
|
|
32
33
|
image_resize = image.resize(size)
|
|
33
34
|
# Save the image into the existing png file, overwriting if exists
|
|
35
|
+
dirname = os.path.dirname(output_fpath)
|
|
36
|
+
if dirname and not os.path.isdir(dirname):
|
|
37
|
+
os.makedirs(dirname)
|
|
34
38
|
image_resize.save(
|
|
35
39
|
os.path.abspath(output_fpath), "png", quality=95, dpi=(300, 300)
|
|
36
40
|
)
|
|
@@ -59,7 +59,7 @@ class LocalProject(BaseModel):
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
@app.get("/")
|
|
62
|
-
def get_root() -> list[LocalProject]:
|
|
62
|
+
def get_root(get_jupyter_servers: bool = True) -> list[LocalProject]:
|
|
63
63
|
"""Return information about the current running server.
|
|
64
64
|
|
|
65
65
|
- The project owner
|
|
@@ -68,9 +68,15 @@ def get_root() -> list[LocalProject]:
|
|
|
68
68
|
- A Jupyter server running here, if applicable
|
|
69
69
|
"""
|
|
70
70
|
resp = []
|
|
71
|
+
logger.info("Finding project directories")
|
|
71
72
|
project_dirs = calkit.find_project_dirs()
|
|
72
|
-
|
|
73
|
+
if get_jupyter_servers:
|
|
74
|
+
logger.info("Getting Jupyter servers")
|
|
75
|
+
servers = calkit.jupyter.get_servers()
|
|
76
|
+
else:
|
|
77
|
+
servers = []
|
|
73
78
|
for pdir in project_dirs:
|
|
79
|
+
logger.info(f"Inspecting {pdir}")
|
|
74
80
|
try:
|
|
75
81
|
project = calkit.git.detect_project_name(path=pdir)
|
|
76
82
|
except ValueError:
|
|
@@ -96,8 +102,10 @@ def get_root() -> list[LocalProject]:
|
|
|
96
102
|
|
|
97
103
|
|
|
98
104
|
@app.get("/projects/{owner_name}/{project_name}")
|
|
99
|
-
def get_local_project(
|
|
100
|
-
|
|
105
|
+
def get_local_project(
|
|
106
|
+
owner_name: str, project_name: str, get_jupyter_server: bool = True
|
|
107
|
+
) -> LocalProject:
|
|
108
|
+
all_projects = get_root(get_jupyter_servers=get_jupyter_server)
|
|
101
109
|
for project in all_projects:
|
|
102
110
|
if (
|
|
103
111
|
project.owner_name == owner_name
|
|
@@ -235,14 +243,22 @@ class Status(BaseModel):
|
|
|
235
243
|
|
|
236
244
|
|
|
237
245
|
@app.get("/projects/{owner_name}/{project_name}/status")
|
|
238
|
-
def get_status(
|
|
246
|
+
def get_status(
|
|
247
|
+
owner_name: str,
|
|
248
|
+
project_name: str,
|
|
249
|
+
fetch_git: bool = True,
|
|
250
|
+
fetch_dvc: bool = True,
|
|
251
|
+
):
|
|
239
252
|
"""Get status in working directory, from both Git and DVC."""
|
|
240
253
|
errors = []
|
|
241
254
|
logger.info(f"Looking for project {owner_name}/{project_name}")
|
|
242
|
-
project = get_local_project(
|
|
255
|
+
project = get_local_project(
|
|
256
|
+
owner_name, project_name, get_jupyter_server=False
|
|
257
|
+
)
|
|
243
258
|
logger.info(f"Found project at {project.wdir}")
|
|
244
259
|
git_repo = git.Repo(project.wdir)
|
|
245
|
-
|
|
260
|
+
if fetch_git:
|
|
261
|
+
git_repo.git.fetch()
|
|
246
262
|
untracked_git_files = git_repo.untracked_files
|
|
247
263
|
# Get a list of diffs of the working tree to the index
|
|
248
264
|
git_diff = git_repo.index.diff(None)
|
|
@@ -281,13 +297,17 @@ def get_status(owner_name: str, project_name: str):
|
|
|
281
297
|
dvc_pipeline_status = dvc.repo.status.status(dvc_repo)
|
|
282
298
|
# Remove any always changed entries so the pipeline doesn't look
|
|
283
299
|
# out of date
|
|
300
|
+
logger.info(f"Raw DVC pipeline status: {dvc_pipeline_status}")
|
|
284
301
|
dvc_pipeline_status = {
|
|
285
|
-
k: v
|
|
302
|
+
k.split("dvc.yaml:")[-1]: v
|
|
286
303
|
for k, v in dvc_pipeline_status.items()
|
|
287
|
-
if v != ["always changed"] and "dvc
|
|
304
|
+
if v != ["always changed"] and not k.endswith(".dvc")
|
|
288
305
|
}
|
|
306
|
+
logger.info(
|
|
307
|
+
f"DVC pipeline status after filtering: {dvc_pipeline_status}"
|
|
308
|
+
)
|
|
289
309
|
dvc_data_status = dvc.repo.data.status(
|
|
290
|
-
dvc_repo, not_in_remote=
|
|
310
|
+
dvc_repo, not_in_remote=fetch_dvc, remote_refresh=fetch_dvc
|
|
291
311
|
)
|
|
292
312
|
# Reformat this a bit, since it can be a little hard to understand
|
|
293
313
|
# DVC calls a path committed when its DVC file is staged
|
|
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
|
|
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
|