Skip to content

Commit

Permalink
Merge pull request #1 from Kiln-AI/packaging
Browse files Browse the repository at this point in the history
Monorepo
  • Loading branch information
scosman authored Aug 19, 2024
2 parents c548c55 + e60332d commit 207367f
Show file tree
Hide file tree
Showing 29 changed files with 359 additions and 195 deletions.
36 changes: 22 additions & 14 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,34 @@ jobs:

- run: pip install -r requirements.txt

- name: Install Core
run: poetry install
working-directory: ./libs/core

- name: Build Core
run: hatch build
working-directory: ./core
run: poetry build
working-directory: ./libs/core

- name: Test Core
run: hatch test
working-directory: ./core
run: python3 -m pytest tests/
working-directory: ./libs/core

- name: Check Types Core
run: mypy --install-types --non-interactive .
working-directory: ./src/core
# Remove this later: needed as server expects this dir to exist
- name: Mock Studio Web UI
run: mkdir -p ./src/web_ui/build

- name: Test Studio
run: python3 -m pytest tests/
working-directory: ./libs/studio

- name: Build Studio
run: hatch build
working-directory: ./studio
run: poetry build
working-directory: ./libs/studio

- name: Test Studio
run: hatch test
working-directory: ./studio
- name: Check Types Core
run: pyright .
working-directory: ./libs/core

- name: Check Types Studio
run: mypy --install-types --non-interactive .
working-directory: ./src/studio
run: pyright .
working-directory: ./libs/studio
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"eslint.validate": ["javascript", "javascriptreact", "svelte"],
// Svelte, JS, TS files
"[javascript, typescript, svelte, json]": {
"editor.defaultFormatter": "svelte.svelte-vscode",
}
}
"editor.defaultFormatter": "svelte.svelte-vscode"
},
"python.testing.pytestArgs": ["."],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
22 changes: 11 additions & 11 deletions checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ else
fi

echo "${headerStart}Checking Core: build, test${headerEnd}"
cd core
hatch build
hatch test
cd ..
cd libs/core
poetry install
python3 -m pytest tests/
cd ../..

echo "${headerStart}Checking Studio: build, test${headerEnd}"
cd studio
hatch build
hatch test
cd ..
cd libs/studio
# note: don't install, or it will fetch pypi version of core instead of local
python3 -m pytest tests/
cd ../..

echo "${headerStart}Checking Types${headerEnd}"
cd src/core
mypy --install-types --non-interactive .
cd libs/core
pyright .
cd ../studio
mypy --install-types --non-interactive .
pyright .
cd ../..
67 changes: 0 additions & 67 deletions core/pyproject.toml

This file was deleted.

10 changes: 0 additions & 10 deletions core/tests/test_example.py

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion core/README.md → libs/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
## Installation

```console
pip install kiln-ai
pip install kiln_ai
```
2 changes: 1 addition & 1 deletion src/core/coreadd.py → libs/core/kiln_ai/coreadd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# TODO_P0: remove example function
def add(a, b):
def add(a, b) -> int:
return a + b
3 changes: 3 additions & 0 deletions libs/core/kiln_ai/datamodel/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .project import KilnProject

__all__ = ["KilnProject"]
15 changes: 15 additions & 0 deletions libs/core/kiln_ai/datamodel/project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pydantic import BaseModel
from typing import Optional


class KilnProject(BaseModel):
version: int = 1
name: str
path: Optional[str] = None

def __init__(self, name: str, path: Optional[str] = None):
# TODO: learn about pydantic init
super().__init__(name=name, path=path)
if path is not None and name is not None:
# path and name are mutually exclusive for constructor, name comes from path if passed
raise ValueError("path and name are mutually exclusive")
101 changes: 101 additions & 0 deletions libs/core/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions libs/core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kiln-ai"
version = "0.0.4"
readme = "README.md"
description = 'Kiln AI'
authors = [
"Steve Cosman, Chesterfield Laboratories Inc <[email protected]>",
]
license = "Proprietary"
homepage = "https://kiln-ai.com"
repository = "https://github.com/Kiln-AI/kiln"
documentation = "https://github.com/Kiln-AI/kiln#readme"

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/Kiln-AI/kiln/issues"

[tool.poetry.dependencies]
python = ">=3.9"

[tool.poetry.dev-dependencies]
pytest = "^7.2"

[tool.pyright]
strictListInference = true
reportMissingTypeArgument = true
1 change: 1 addition & 0 deletions libs/core/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# empty, but needed by setuptools
11 changes: 11 additions & 0 deletions libs/core/tests/test_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import kiln_ai.coreadd as coreadd
import kiln_ai.datamodel as datamodel


def test_coreadd():
assert coreadd.add(1, 1) == 2


def test_project_init():
project = datamodel.KilnProject(name="test")
assert project.name == "test"
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/studio/server.py → libs/studio/kiln_studio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# TODO would rather this get passed. This class shouldn't know about desktop
def studio_path():
try:
base_path = sys._MEIPASS
base_path = sys._MEIPASS # type: ignore
except Exception:
base_path = os.path.join(os.path.dirname(__file__), "..")

return os.path.join(base_path, "web_ui/build")
return os.path.join(base_path, "../../src/web_ui/build")


app = FastAPI()
Expand All @@ -38,7 +38,7 @@ def load_settings():


@app.post("/setting")
def update_settings(new_settings: dict):
def update_settings(new_settings: dict[str, int | float | str | bool]):
settings = load_settings()
settings.update(new_settings)
with open(settings_path(), "w") as f:
Expand Down
Loading

0 comments on commit 207367f

Please sign in to comment.