calkit-python 0.20.2__tar.gz → 0.20.4__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.
Files changed (143) hide show
  1. {calkit_python-0.20.2 → calkit_python-0.20.4}/PKG-INFO +1 -1
  2. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/__init__.py +1 -1
  3. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cli/import_.py +61 -6
  4. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cli/main.py +2 -0
  5. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cli/new.py +10 -2
  6. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/core.py +27 -5
  7. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/dvc.py +1 -1
  8. calkit_python-0.20.4/calkit/git.py +15 -0
  9. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/server.py +1 -1
  10. calkit_python-0.20.4/calkit/tests/test_core.py +60 -0
  11. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/pipeline/index.md +3 -0
  12. {calkit_python-0.20.2 → calkit_python-0.20.4}/pyproject.toml +1 -0
  13. {calkit_python-0.20.2 → calkit_python-0.20.4}/uv.lock +3 -1
  14. calkit_python-0.20.2/calkit/git.py +0 -36
  15. calkit_python-0.20.2/calkit/tests/test_core.py +0 -13
  16. {calkit_python-0.20.2 → calkit_python-0.20.4}/.github/FUNDING.yml +0 -0
  17. {calkit_python-0.20.2 → calkit_python-0.20.4}/.github/workflows/docs.yml +0 -0
  18. {calkit_python-0.20.2 → calkit_python-0.20.4}/.github/workflows/publish-test.yml +0 -0
  19. {calkit_python-0.20.2 → calkit_python-0.20.4}/.github/workflows/publish.yml +0 -0
  20. {calkit_python-0.20.2 → calkit_python-0.20.4}/.gitignore +0 -0
  21. {calkit_python-0.20.2 → calkit_python-0.20.4}/.pre-commit-config.yaml +0 -0
  22. {calkit_python-0.20.2 → calkit_python-0.20.4}/CONTRIBUTING.md +0 -0
  23. {calkit_python-0.20.2 → calkit_python-0.20.4}/LICENSE +0 -0
  24. {calkit_python-0.20.2 → calkit_python-0.20.4}/Makefile +0 -0
  25. {calkit_python-0.20.2 → calkit_python-0.20.4}/README.md +0 -0
  26. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/__main__.py +0 -0
  27. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/calc.py +0 -0
  28. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/check.py +0 -0
  29. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cli/__init__.py +0 -0
  30. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cli/check.py +0 -0
  31. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cli/config.py +0 -0
  32. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cli/core.py +0 -0
  33. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cli/list.py +0 -0
  34. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cli/notebooks.py +0 -0
  35. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cli/office.py +0 -0
  36. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cli/update.py +0 -0
  37. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/cloud.py +0 -0
  38. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/conda.py +0 -0
  39. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/config.py +0 -0
  40. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/datasets.py +0 -0
  41. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/docker.py +0 -0
  42. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/github.py +0 -0
  43. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/gui.py +0 -0
  44. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/jupyter.py +0 -0
  45. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/magics.py +0 -0
  46. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/models.py +0 -0
  47. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/office.py +0 -0
  48. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/ops.py +0 -0
  49. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/releases.py +0 -0
  50. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/templates/__init__.py +0 -0
  51. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/templates/core.py +0 -0
  52. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/templates/latex/__init__.py +0 -0
  53. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/templates/latex/article/paper.tex +0 -0
  54. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/templates/latex/core.py +0 -0
  55. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/templates/latex/jfm/jfm.bst +0 -0
  56. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/templates/latex/jfm/jfm.cls +0 -0
  57. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/templates/latex/jfm/lineno-FLM.sty +0 -0
  58. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/templates/latex/jfm/paper.tex +0 -0
  59. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/templates/latex/jfm/upmath.sty +0 -0
  60. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/__init__.py +0 -0
  61. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/cli/__init__.py +0 -0
  62. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/cli/test_list.py +0 -0
  63. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/cli/test_main.py +0 -0
  64. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/cli/test_new.py +0 -0
  65. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/test_calc.py +0 -0
  66. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/test_check.py +0 -0
  67. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/test_conda.py +0 -0
  68. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/test_dvc.py +0 -0
  69. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/test_jupyter.py +0 -0
  70. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/test_magics.py +0 -0
  71. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/tests/test_templates.py +0 -0
  72. {calkit_python-0.20.2 → calkit_python-0.20.4}/calkit/zenodo.py +0 -0
  73. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/CNAME +0 -0
  74. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/apps.md +0 -0
  75. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/calculations.md +0 -0
  76. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/calkit-yaml.md +0 -0
  77. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/cli-reference.md +0 -0
  78. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/cloud-integration.md +0 -0
  79. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/datasets.md +0 -0
  80. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/environments.md +0 -0
  81. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/examples.md +0 -0
  82. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/help.md +0 -0
  83. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/img/c-to-the-k-white.svg +0 -0
  84. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/img/calkit-no-bg.png +0 -0
  85. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/img/connect-zenodo.png +0 -0
  86. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/index.md +0 -0
  87. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/installation.md +0 -0
  88. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/local-server.md +0 -0
  89. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/pipeline/manual-steps.md +0 -0
  90. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/references.md +0 -0
  91. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/releases.md +0 -0
  92. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/adding-latex-pub-docker.md +0 -0
  93. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/conda-envs.md +0 -0
  94. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/existing-project.md +0 -0
  95. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/first-project.md +0 -0
  96. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/building-codespace.png +0 -0
  97. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/codespaces-secrets-2.png +0 -0
  98. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/editor-split.png +0 -0
  99. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/go-to-linked-code.png +0 -0
  100. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/issue-from-selection.png +0 -0
  101. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/new-project.png +0 -0
  102. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/new-pub-2.png +0 -0
  103. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/new-token.png +0 -0
  104. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/paper.tex.png +0 -0
  105. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/project-home-3.png +0 -0
  106. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/push.png +0 -0
  107. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/latex-codespaces/stage.png +0 -0
  108. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/anakin-excel.jpg +0 -0
  109. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/chart-more-rows.png +0 -0
  110. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/create-project.png +0 -0
  111. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/elsevier-research-data-guidelines.png +0 -0
  112. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/excel-chart.png +0 -0
  113. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/excel-data.png +0 -0
  114. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/insert-link-to-file.png +0 -0
  115. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/needs-clone.png +0 -0
  116. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/new-stage.png +0 -0
  117. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/phd-comics-version-control.webp +0 -0
  118. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/pipeline-out-of-date.png +0 -0
  119. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/status-more-rows.png +0 -0
  120. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/uncommitted-changes.png +0 -0
  121. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/untracked-data.png +0 -0
  122. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/updated-publication.png +0 -0
  123. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/word-to-pdf-stage-2.png +0 -0
  124. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/office/workflow-page.png +0 -0
  125. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/openfoam/clone.png +0 -0
  126. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/openfoam/create-project.png +0 -0
  127. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/openfoam/datasets-page.png +0 -0
  128. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/openfoam/figure-on-website-updated.png +0 -0
  129. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/openfoam/figure-on-website.png +0 -0
  130. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/openfoam/new-token.png +0 -0
  131. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/openfoam/reclone.png +0 -0
  132. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/openfoam/status-after-import-dataset.png +0 -0
  133. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/img/run-proc.png +0 -0
  134. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/index.md +0 -0
  135. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/latex-codespaces.md +0 -0
  136. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/matlab.md +0 -0
  137. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/notebook-pipeline.md +0 -0
  138. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/office.md +0 -0
  139. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/openfoam.md +0 -0
  140. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/tutorials/procedures.md +0 -0
  141. {calkit_python-0.20.2 → calkit_python-0.20.4}/docs/version-control.md +0 -0
  142. {calkit_python-0.20.2 → calkit_python-0.20.4}/mkdocs.yml +0 -0
  143. {calkit_python-0.20.2 → calkit_python-0.20.4}/test/pipeline.ipynb +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: calkit-python
3
- Version: 0.20.2
3
+ Version: 0.20.4
4
4
  Summary: Reproducibility simplified.
5
5
  Project-URL: Homepage, https://calkit.org
6
6
  Project-URL: Issues, https://github.com/calkit/calkit/issues
@@ -1,4 +1,4 @@
1
- __version__ = "0.20.2"
1
+ __version__ = "0.20.4"
2
2
 
3
3
  from .core import *
4
4
  from . import git
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  import base64
6
6
  import os
7
7
  import subprocess
8
+ from copy import deepcopy
8
9
  from typing import Annotated
9
10
 
10
11
  import git
@@ -208,7 +209,7 @@ def import_dataset(
208
209
 
209
210
  @import_app.command(name="environment")
210
211
  def import_environment(
211
- src_path: Annotated[
212
+ src: Annotated[
212
213
  str,
213
214
  typer.Argument(
214
215
  help=(
@@ -236,12 +237,66 @@ def import_environment(
236
237
  help="Force adding the dataset even if it already exists.",
237
238
  ),
238
239
  ] = False,
240
+ no_commit: Annotated[
241
+ bool, typer.Option("--no-commit", help="Do not commit changes.")
242
+ ] = False,
239
243
  ) -> None:
240
- project, env_name = src_path.split(":")
244
+ """Import an environment from another project."""
245
+ raise_error(
246
+ "This command is not yet implemented; "
247
+ "please thumbs-up this issue if you'd like to see "
248
+ "it finished: https://github.com/calkit/calkit/issues/239"
249
+ )
250
+ try:
251
+ project, env_name = src.split(":")
252
+ except ValueError:
253
+ raise_error("Invalid source environment specification")
241
254
  if os.path.isdir(project):
242
- cloud = False
243
- typer.echo("Importing from local project directory")
255
+ typer.echo(f"Importing from local project directory: {project}")
256
+ src_ck_info = calkit.load_calkit_info(
257
+ wdir=project, process_includes=True
258
+ )
259
+ environments = src_ck_info.get("environments", {})
260
+ if env_name not in environments:
261
+ raise_error(f"Environment {env_name} not found in project")
262
+ src_env = environments[env_name]
263
+ if "path" in src_env:
264
+ env_path = src_env["path"]
265
+ try:
266
+ src_project_name = calkit.detect_project_name(project)
267
+ except Exception as e:
268
+ raise_error(f"Could not detect source project name: {e}")
244
269
  else:
245
- cloud = True
246
270
  typer.echo("Importing from Cloud project")
247
- raise_error("Not yet implemented") # TODO
271
+ try:
272
+ resp = calkit.cloud.get(
273
+ f"/projects/{project}/environments/{env_name}"
274
+ )
275
+ except Exception as e:
276
+ raise_error(f"Failed to fetch environment info from cloud: {e}")
277
+ src_project_name = project
278
+ # TODO: Parse information we need from the response
279
+ # Write environment into current Calkit info
280
+ ck_info = calkit.load_calkit_info()
281
+ environments = ck_info.get("environments", {})
282
+ # Check if an environment with this name already exists
283
+ if dest_name is None:
284
+ dest_name = env_name
285
+ if dest_name in environments and not overwrite:
286
+ raise_error("An environment with this name already exists")
287
+ # If source env is imported, don't update that field
288
+ new_env = deepcopy(src_env)
289
+ if "imported_from" not in new_env:
290
+ new_env["imported_from"]["project"] = src_project_name
291
+ if dest_path is not None and "path" in new_env:
292
+ new_env["path"] = dest_path
293
+ # TODO: Write the environment content to file if necessary
294
+ new_env = dict(imported_from=dict(project=project))
295
+ environments[dest_name] = new_env
296
+ ck_info["environments"] = environments
297
+ with open("calkit.yaml", "w") as f:
298
+ calkit.ryaml.dump(ck_info, f)
299
+ repo = git.Repo()
300
+ repo.git.add("calkit.yaml")
301
+ if not no_commit and calkit.git.get_staged_files():
302
+ repo.git.commit(["-m", f"Import environment {src}"])
@@ -856,6 +856,8 @@ def run_in_env(
856
856
  ]
857
857
  if platform:
858
858
  docker_cmd += ["--platform", platform]
859
+ if docker_user := env.get("user"):
860
+ docker_cmd += ["--user", docker_user]
859
861
  docker_cmd += env.get("args", [])
860
862
  docker_cmd += [
861
863
  "-it" if sys.stdin.isatty() else "-i",
@@ -159,7 +159,7 @@ def new_project(
159
159
  calkit.dvc.set_remote_auth(wdir=abs_path)
160
160
  except Exception:
161
161
  warn("Failed to setup Calkit DVC remote auth")
162
- prj = calkit.git.detect_project_name(path=abs_path)
162
+ prj = calkit.detect_project_name(wdir=abs_path)
163
163
  add_msg = f"\n\nYou can view your project at https://calkit.io/{prj}"
164
164
  typer.echo(success_message + add_msg)
165
165
  return
@@ -498,6 +498,12 @@ def new_docker_env(
498
498
  wdir: Annotated[
499
499
  str, typer.Option("--wdir", help="Working directory.")
500
500
  ] = "/work",
501
+ user: Annotated[
502
+ str,
503
+ typer.Option(
504
+ "--user", help="User account to use to run the container."
505
+ ),
506
+ ] = None,
501
507
  platform: Annotated[
502
508
  str, typer.Option("--platform", help="Which platform(s) to build for.")
503
509
  ] = None,
@@ -563,6 +569,8 @@ def new_docker_env(
563
569
  env["layers"] = layers
564
570
  if platform:
565
571
  env["platform"] = platform
572
+ if user:
573
+ env["user"] = user
566
574
  envs[name] = env
567
575
  ck_info["environments"] = envs
568
576
  with open("calkit.yaml", "w") as f:
@@ -1604,7 +1612,7 @@ def new_release(
1604
1612
  # Is there already a deposition for this release, which indicates we should
1605
1613
  # create a new version?
1606
1614
  zenodo_dep_id = None
1607
- project_name = calkit.git.detect_project_name()
1615
+ project_name = calkit.detect_project_name()
1608
1616
  zenodo_metadata = dict(
1609
1617
  title=title,
1610
1618
  description=description,
@@ -12,10 +12,10 @@ import pickle
12
12
  import re
13
13
  import subprocess
14
14
 
15
- from calkit.models import ProjectStatus
16
-
17
15
  import requests
18
16
 
17
+ from calkit.models import ProjectStatus
18
+
19
19
  try:
20
20
  from datetime import UTC
21
21
  except ImportError:
@@ -107,9 +107,12 @@ def load_calkit_info(
107
107
  for obj_name, obj in info[kind].items():
108
108
  if "_include" in obj:
109
109
  include_fpath = obj.pop("_include")
110
- with open(include_fpath) as f:
111
- include_data = ryaml.load(f)
112
- info[kind][obj_name] |= include_data
110
+ if wdir is not None:
111
+ include_fpath = os.path.join(wdir, include_fpath)
112
+ if os.path.isfile(include_fpath):
113
+ with open(include_fpath) as f:
114
+ include_data = ryaml.load(f)
115
+ info[kind][obj_name] |= include_data
113
116
  if as_pydantic:
114
117
  return ProjectInfo.model_validate(info)
115
118
  return info
@@ -417,3 +420,22 @@ def get_latest_project_status(wdir: str = None) -> ProjectStatus | None:
417
420
  statuses = get_project_status_history(wdir=wdir)
418
421
  if statuses:
419
422
  return statuses[-1]
423
+
424
+
425
+ def detect_project_name(wdir: str = None) -> str:
426
+ """Detect a Calkit project owner and name."""
427
+ ck_info = load_calkit_info(wdir=wdir)
428
+ name = ck_info.get("name")
429
+ owner = ck_info.get("owner")
430
+ if name is None or owner is None:
431
+ try:
432
+ url = Repo(path=wdir).remote().url
433
+ except ValueError:
434
+ raise ValueError("No Git remote set with name 'origin'")
435
+ from_url = url.split("github.com")[-1][1:].removesuffix(".git")
436
+ owner_name, project_name = from_url.split("/")
437
+ if name is None:
438
+ name = project_name
439
+ if owner is None:
440
+ owner = owner_name
441
+ return f"{owner}/{name}"
@@ -19,7 +19,7 @@ logger.setLevel(logging.INFO)
19
19
 
20
20
  def configure_remote(wdir: str = None):
21
21
  try:
22
- project_name = calkit.git.detect_project_name(path=wdir)
22
+ project_name = calkit.detect_project_name(wdir=wdir)
23
23
  except ValueError as e:
24
24
  raise ValueError(f"Can't detect project name: {e}")
25
25
  # If Git origin is not set, set that
@@ -0,0 +1,15 @@
1
+ """Git-related functionality."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import git
6
+
7
+
8
+ def get_staged_files(path: str = None) -> list[str]:
9
+ repo = git.Repo(path)
10
+ cmd = ["--staged", "--name-only"]
11
+ if path is not None:
12
+ cmd.append(path)
13
+ diff = repo.git.diff(cmd)
14
+ paths = diff.split("\n")
15
+ return paths
@@ -79,7 +79,7 @@ def get_root(get_jupyter_servers: bool = True) -> list[LocalProject]:
79
79
  for pdir in project_dirs:
80
80
  logger.info(f"Inspecting {pdir}")
81
81
  try:
82
- project = calkit.git.detect_project_name(path=pdir)
82
+ project = calkit.detect_project_name(wdir=pdir)
83
83
  except ValueError:
84
84
  logger.warning(f"Can't detect project name in {pdir}")
85
85
  continue
@@ -0,0 +1,60 @@
1
+ """Tests for the ``core`` module."""
2
+
3
+ import os
4
+ import subprocess
5
+
6
+ import git
7
+
8
+ import calkit
9
+
10
+
11
+ def test_find_project_dirs():
12
+ calkit.find_project_dirs()
13
+ assert calkit.find_project_dirs(relative=False)
14
+
15
+
16
+ def test_to_kebab_case():
17
+ assert calkit.to_kebab_case("THIS IS") == "this-is"
18
+ assert calkit.to_kebab_case("this_is_my-Project") == "this-is-my-project"
19
+
20
+
21
+ def test_detect_project_name(tmp_dir):
22
+ subprocess.check_output(["calkit", "init"])
23
+ repo = git.Repo()
24
+ repo.create_remote("origin", "https://github.com/someone/some-repo.git")
25
+ assert calkit.detect_project_name() == "someone/some-repo"
26
+ with open("calkit.yaml", "w") as f:
27
+ f.write("owner: someone-else\nname: some-project\n")
28
+ assert calkit.detect_project_name() == "someone-else/some-project"
29
+
30
+
31
+ def test_load_calkit_info(tmp_dir):
32
+ subpath = "some/project"
33
+ os.makedirs(subpath)
34
+ os.makedirs(subpath + "/.calkit/environments")
35
+ with open(subpath + "/.calkit/environments/env2.yaml", "w") as f:
36
+ calkit.ryaml.dump({"kind": "docker", "image": "openfoam"}, f)
37
+ with open(subpath + "/calkit.yaml", "w") as f:
38
+ calkit.ryaml.dump(
39
+ {
40
+ "name": "some-project",
41
+ "owner": "someone",
42
+ "environments": {
43
+ "env1": {"kind": "docker", "image": "ubuntu"},
44
+ "env2": {"_include": ".calkit/environments/env2.yaml"},
45
+ },
46
+ },
47
+ f,
48
+ )
49
+ ck_info = calkit.load_calkit_info(wdir=subpath)
50
+ assert ck_info["environments"]["env1"]["image"] == "ubuntu"
51
+ assert ck_info["environments"]["env2"] == {
52
+ "_include": ".calkit/environments/env2.yaml"
53
+ }
54
+ ck_info = calkit.load_calkit_info(wdir=subpath, process_includes=True)
55
+ assert ck_info["environments"]["env1"]["image"] == "ubuntu"
56
+ assert ck_info["environments"]["env2"]["image"] == "openfoam"
57
+ os.chdir(subpath)
58
+ ck_info = calkit.load_calkit_info(process_includes=True)
59
+ assert ck_info["environments"]["env1"]["image"] == "ubuntu"
60
+ assert ck_info["environments"]["env2"]["image"] == "openfoam"
@@ -35,3 +35,6 @@ stages:
35
35
  title: The raw data
36
36
  description: Raw voltage, collected from the sensor.
37
37
  ```
38
+
39
+ To learn more, see
40
+ [DVC's pipeline documentation](https://dvc.org/doc/start/data-pipelines/data-pipelines).
@@ -53,6 +53,7 @@ dev = [
53
53
  "kaleido==0.2.1",
54
54
  "numpy",
55
55
  "pandas>=2.2.3",
56
+ "polars>=1.18.0",
56
57
  "plotly",
57
58
  "pre-commit",
58
59
  "pyarrow",
@@ -396,7 +396,7 @@ css = [
396
396
 
397
397
  [[package]]
398
398
  name = "calkit-python"
399
- version = "0.20.0"
399
+ version = "0.20.3"
400
400
  source = { editable = "." }
401
401
  dependencies = [
402
402
  { name = "arithmeval" },
@@ -440,6 +440,7 @@ dev = [
440
440
  { name = "numpy", version = "2.2.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
441
441
  { name = "pandas" },
442
442
  { name = "plotly" },
443
+ { name = "polars" },
443
444
  { name = "pre-commit" },
444
445
  { name = "pyarrow" },
445
446
  { name = "pytest" },
@@ -485,6 +486,7 @@ dev = [
485
486
  { name = "numpy" },
486
487
  { name = "pandas", specifier = ">=2.2.3" },
487
488
  { name = "plotly" },
489
+ { name = "polars", specifier = ">=1.18.0" },
488
490
  { name = "pre-commit" },
489
491
  { name = "pyarrow" },
490
492
  { name = "pytest" },
@@ -1,36 +0,0 @@
1
- """Git-related functionality."""
2
-
3
- from __future__ import annotations
4
-
5
- import git
6
-
7
- import calkit
8
-
9
-
10
- def detect_project_name(path: str = None) -> str:
11
- """Read the project owner and name from the remote."""
12
- ck_info = calkit.load_calkit_info(wdir=path)
13
- name = ck_info.get("name")
14
- owner = ck_info.get("owner")
15
- if name is None or owner is None:
16
- try:
17
- url = git.Repo(path=path).remote().url
18
- except ValueError:
19
- raise ValueError("No Git remote set with name 'origin'")
20
- from_url = url.split("github.com")[-1][1:].removesuffix(".git")
21
- owner_name, project_name = from_url.split("/")
22
- if name is None:
23
- name = project_name
24
- if owner is None:
25
- owner = owner_name
26
- return f"{owner}/{name}"
27
-
28
-
29
- def get_staged_files(path: str = None) -> list[str]:
30
- repo = git.Repo(path)
31
- cmd = ["--staged", "--name-only"]
32
- if path is not None:
33
- cmd.append(path)
34
- diff = repo.git.diff(cmd)
35
- paths = diff.split("\n")
36
- return paths
@@ -1,13 +0,0 @@
1
- """Tests for the ``core`` module."""
2
-
3
- import calkit
4
-
5
-
6
- def test_find_project_dirs():
7
- calkit.find_project_dirs()
8
- assert calkit.find_project_dirs(relative=False)
9
-
10
-
11
- def test_to_kebab_case():
12
- assert calkit.to_kebab_case("THIS IS") == "this-is"
13
- assert calkit.to_kebab_case("this_is_my-Project") == "this-is-my-project"
File without changes
File without changes
File without changes