calkit-python 0.0.2__tar.gz → 0.0.3__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 (30) hide show
  1. {calkit_python-0.0.2 → calkit_python-0.0.3}/PKG-INFO +5 -4
  2. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/__init__.py +1 -1
  3. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/cli.py +59 -1
  4. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/core.py +10 -0
  5. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/data.py +6 -1
  6. calkit_python-0.0.3/calkit/models.py +74 -0
  7. {calkit_python-0.0.2 → calkit_python-0.0.3}/pyproject.toml +26 -22
  8. {calkit_python-0.0.2 → calkit_python-0.0.3}/.github/FUNDING.yml +0 -0
  9. {calkit_python-0.0.2 → calkit_python-0.0.3}/.github/workflows/publish-test.yml +0 -0
  10. {calkit_python-0.0.2 → calkit_python-0.0.3}/.github/workflows/publish.yml +0 -0
  11. {calkit_python-0.0.2 → calkit_python-0.0.3}/.gitignore +0 -0
  12. {calkit_python-0.0.2 → calkit_python-0.0.3}/LICENSE +0 -0
  13. {calkit_python-0.0.2 → calkit_python-0.0.3}/README.md +0 -0
  14. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/cloud.py +0 -0
  15. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/config.py +0 -0
  16. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/dvc.py +0 -0
  17. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/git.py +0 -0
  18. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/gui.py +0 -0
  19. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/jupyter.py +0 -0
  20. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/server.py +0 -0
  21. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/tests/__init__.py +0 -0
  22. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/tests/test_core.py +0 -0
  23. {calkit_python-0.0.2 → calkit_python-0.0.3}/calkit/tests/test_jupyter.py +0 -0
  24. {calkit_python-0.0.2 → calkit_python-0.0.3}/examples/cfd-study/README.md +0 -0
  25. {calkit_python-0.0.2 → calkit_python-0.0.3}/examples/cfd-study/calkit.yaml +0 -0
  26. {calkit_python-0.0.2 → calkit_python-0.0.3}/examples/cfd-study/config/simulations/runs.csv +0 -0
  27. {calkit_python-0.0.2 → calkit_python-0.0.3}/examples/cfd-study/notebook.ipynb +0 -0
  28. {calkit_python-0.0.2 → calkit_python-0.0.3}/examples/ms-office/.gitignore +0 -0
  29. {calkit_python-0.0.2 → calkit_python-0.0.3}/examples/ms-office/README.md +0 -0
  30. {calkit_python-0.0.2 → calkit_python-0.0.3}/examples/ms-office/calkit.yaml +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: calkit-python
3
- Version: 0.0.2
4
- Summary: Reproducibility made easy.
3
+ Version: 0.0.3
4
+ Summary: Reproducibility simplified.
5
5
  Project-URL: Homepage, https://github.com/calkit/calkit
6
6
  Project-URL: Issues, https://github.com/calkit/calkit/issues
7
7
  Author-email: Pete Bachant <petebachant@gmail.com>
@@ -15,13 +15,14 @@ Requires-Dist: eval-type-backport; python_version < '3.10'
15
15
  Requires-Dist: fastapi
16
16
  Requires-Dist: gitpython
17
17
  Requires-Dist: keyring
18
- Requires-Dist: pandas
19
- Requires-Dist: polars
20
18
  Requires-Dist: pydantic-settings
21
19
  Requires-Dist: pydantic[email]
22
20
  Requires-Dist: pyjwt
23
21
  Requires-Dist: requests
24
22
  Requires-Dist: typer
23
+ Provides-Extra: data
24
+ Requires-Dist: pandas; extra == 'data'
25
+ Requires-Dist: polars; extra == 'data'
25
26
  Description-Content-Type: text/markdown
26
27
 
27
28
  # Calkit
@@ -1,4 +1,4 @@
1
- __version__ = "0.0.2"
1
+ __version__ = "0.0.3"
2
2
 
3
3
  from .core import *
4
4
  from . import git
@@ -7,17 +7,20 @@ import pty
7
7
  import subprocess
8
8
  import sys
9
9
 
10
+ import git
10
11
  import typer
11
12
  from typing_extensions import Annotated, Optional
12
13
 
13
- import calkit
14
+ from calkit.core import ryaml
14
15
 
15
16
  from . import config
16
17
  from .dvc import configure_remote, set_remote_auth
17
18
 
18
19
  app = typer.Typer()
19
20
  config_app = typer.Typer()
21
+ new_app = typer.Typer()
20
22
  app.add_typer(config_app, name="config", help="Configure Calkit.")
23
+ app.add_typer(new_app, name="new", help="Add new Calkit object.")
21
24
 
22
25
 
23
26
  @config_app.command(name="set")
@@ -102,6 +105,61 @@ def commit(
102
105
  raise NotImplementedError
103
106
 
104
107
 
108
+ @new_app.command(name="figure")
109
+ def new_figure(
110
+ path: str,
111
+ title: Annotated[str, typer.Option("--title")],
112
+ description: Annotated[str, typer.Option("--desc")] = None,
113
+ commit: Annotated[bool, typer.Option("--commit")] = False,
114
+ ):
115
+ """Add a new figure to ``calkit.yaml``."""
116
+ if os.path.isfile("calkit.yaml"):
117
+ with open("calkit.yaml") as f:
118
+ ck_info = ryaml.load(f)
119
+ else:
120
+ ck_info = {}
121
+ figures = ck_info.get("figures", [])
122
+ paths = [f.get("path") for f in figures]
123
+ if path in paths:
124
+ raise ValueError(f"Figure at path {path} already exists")
125
+ obj = dict(path=path, title=title)
126
+ if description is not None:
127
+ obj["description"] = description
128
+ figures.append(obj)
129
+ ck_info["figures"] = figures
130
+ with open("calkit.yaml", "w") as f:
131
+ ryaml.dump(ck_info, f)
132
+ if commit:
133
+ repo = git.Repo()
134
+ repo.git.add("calkit.yaml")
135
+ repo.git.commit(["-m", f"Add figure {path}"])
136
+
137
+
138
+ @new_app.command("question")
139
+ def new_question(
140
+ question: str,
141
+ commit: Annotated[bool, typer.Option("--commit")] = False,
142
+ ):
143
+ if os.path.isfile("calkit.yaml"):
144
+ with open("calkit.yaml") as f:
145
+ ck_info = ryaml.load(f)
146
+ else:
147
+ ck_info = {}
148
+ questions = ck_info.get("questions", [])
149
+ if question in questions:
150
+ raise ValueError("Question already exists")
151
+ if not question.endswith("?"):
152
+ raise ValueError("Questions must end with a question mark")
153
+ questions.append(question)
154
+ ck_info["questions"] = questions
155
+ with open("calkit.yaml", "w") as f:
156
+ ryaml.dump(ck_info, f)
157
+ if commit:
158
+ repo = git.Repo()
159
+ repo.git.add("calkit.yaml")
160
+ repo.git.commit(["-m", "Add question"])
161
+
162
+
105
163
  @app.command(name="server")
106
164
  def run_server():
107
165
  import uvicorn
@@ -3,11 +3,21 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import glob
6
+ import logging
6
7
  import os
7
8
 
9
+ import ruamel.yaml
8
10
  from git import Repo
9
11
  from git.exc import InvalidGitRepositoryError
10
12
 
13
+ logging.basicConfig(level=logging.INFO)
14
+ logger = logging.getLogger(__package__)
15
+
16
+ ryaml = ruamel.yaml.YAML()
17
+ ryaml.indent(mapping=2, sequence=4, offset=2)
18
+ ryaml.preserve_quotes = True
19
+ ryaml.width = 70
20
+
11
21
 
12
22
  def find_project_dirs(relative=False, max_depth=3) -> list[str]:
13
23
  """Find all Calkit project directories."""
@@ -1,4 +1,9 @@
1
- """Functionality for working with datasets."""
1
+ """Functionality for working with datasets.
2
+
3
+ Since the dependencies here are optional, we need to ensure this isn't imported
4
+ by default, or otherwise ensure ``import calkit`` works when the data
5
+ dependencies are not installed.
6
+ """
2
7
 
3
8
  from __future__ import annotations
4
9
 
@@ -0,0 +1,74 @@
1
+ """Data models."""
2
+
3
+ from typing import Literal
4
+
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class _ImportedFrom(BaseModel):
9
+ project: str
10
+ path: str = None
11
+
12
+
13
+ class _CalkitObject(BaseModel):
14
+ path: str
15
+ title: str
16
+ description: str
17
+ stage: str | None = None
18
+
19
+
20
+ class Dataset(_CalkitObject):
21
+ pass
22
+
23
+
24
+ class Figure(_CalkitObject):
25
+ pass
26
+
27
+
28
+ class Publication(_CalkitObject):
29
+ kind: Literal[
30
+ "journal-article",
31
+ "conference-paper",
32
+ "presentation",
33
+ "poster",
34
+ "report",
35
+ "blog",
36
+ ]
37
+ is_published: bool = False
38
+ doi: str = None
39
+
40
+
41
+ class ReferenceFile(BaseModel):
42
+ path: str
43
+ key: str
44
+
45
+
46
+ class ReferenceCollection(BaseModel):
47
+ path: str
48
+ files: list[ReferenceFile] = []
49
+
50
+
51
+ class Environment(BaseModel):
52
+ name: str
53
+ kind: Literal["conda", "docker", "pip", "poetry", "npm", "yarn"]
54
+ path: str
55
+
56
+
57
+ class Software(BaseModel):
58
+ title: str
59
+ path: str
60
+ description: str
61
+
62
+
63
+ class ProjectInfo(BaseModel):
64
+ """All of the project's information or metadata, written to the
65
+ ``calkit.yaml`` file.
66
+ """
67
+
68
+ questions: list[str] = []
69
+ datasets: list[Dataset] = []
70
+ figures: list[Figure] = []
71
+ publications: list[Publication] = []
72
+ references: list[ReferenceCollection] = []
73
+ environments: list[Environment] = []
74
+ software: list[Software] = []
@@ -1,34 +1,38 @@
1
1
  [build-system]
2
- requires = ["hatchling"]
3
2
  build-backend = "hatchling.build"
3
+ requires = ["hatchling"]
4
4
 
5
5
  [project]
6
- name = "calkit-python"
7
- dynamic = ["version"]
8
6
  authors = [
9
- { name="Pete Bachant", email="petebachant@gmail.com" },
7
+ {name = "Pete Bachant", email = "petebachant@gmail.com"},
10
8
  ]
11
- description = "Reproducibility made easy."
12
- readme = "README.md"
13
- requires-python = ">=3.8"
14
9
  classifiers = [
15
- "Programming Language :: Python :: 3",
16
- "License :: OSI Approved :: MIT License",
17
- "Operating System :: OS Independent",
10
+ "Programming Language :: Python :: 3",
11
+ "License :: OSI Approved :: MIT License",
12
+ "Operating System :: OS Independent",
18
13
  ]
19
14
  dependencies = [
20
- "dvc",
21
- "eval-type-backport; python_version < '3.10'",
22
- "fastapi",
23
- "gitpython",
24
- "keyring",
25
- "pandas",
26
- "polars",
27
- "pydantic[email]",
28
- "pydantic-settings",
29
- "pyjwt",
30
- "requests",
31
- "typer",
15
+ "dvc",
16
+ "eval-type-backport; python_version < '3.10'",
17
+ "fastapi",
18
+ "gitpython",
19
+ "keyring",
20
+ "pydantic[email]",
21
+ "pydantic-settings",
22
+ "pyjwt",
23
+ "requests",
24
+ "typer",
25
+ ]
26
+ description = "Reproducibility simplified."
27
+ dynamic = ["version"]
28
+ name = "calkit-python"
29
+ readme = "README.md"
30
+ requires-python = ">=3.8"
31
+
32
+ [project.optional-dependencies]
33
+ data = [
34
+ "pandas",
35
+ "polars",
32
36
  ]
33
37
 
34
38
  [project.urls]
File without changes
File without changes
File without changes