Skip to content

Commit

Permalink
Implement Orchestrator communication.
Browse files Browse the repository at this point in the history
The orchestrator runs an http server. The communication
involves the handshake and the protocol upgrade to the
target capnp server.
  • Loading branch information
tobiasah committed Aug 18, 2023
1 parent 693eb0e commit 39d0639
Show file tree
Hide file tree
Showing 20 changed files with 1,805 additions and 61 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,14 @@ build
.pytest_cache
.mypy_cache
__pycache__
.DS_Store

# coverage
.coverage*
htmlcov

# no jupyter notebooks
*.ipynb

# version fil
_version.py
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ The name of the project and package are still work in progress.
## Contributing

See [Contributing](CONTRIBUTING.md)

# Demo Usage
```python
connection = await Session.create(kernel_info= ZIKernelInfo(), server_info =ServerInfo(host='localhost', port=8004))

await connection._session.listNodesJson("/zi/*").a_wait()
```
181 changes: 123 additions & 58 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,46 +1,7 @@
[tool.hatch]
[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.hatch.version]
path = "src/labone/_version.py"

[tool.hatch.envs.test]
dependencies = [
"pytest"
]

[[tool.hatch.envs.test.matrix]]
python = ["3.9", "3.10", "3.11"]

[tool.hatch.envs.test.scripts]
unit = [
"pytest tests -vv",
]


[tool.hatch.envs.style]
detached = true
dependencies = [
"ruff",
"black",
"isort",
"mypy"
]

[[tool.hatch.envs.style.matrix]]
python = ["3.9", "3.10", "3.11"]

[tool.hatch.envs.style.scripts]
lint = [
"ruff check .",
"black --check --diff .",
]
typing = [
"mypy src/labone"
]

[project]
name = "labone"
dynamic = ["version"]
Expand All @@ -66,22 +27,126 @@ classifiers = [
]
dependencies = []

[project.urls]
Issues = "https://github.com/zhinst/labone-python/issues"
Source = "https://github.com/zhinst/labone-python"

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "src/labone/_version.py"

[tool.hatch.build.targets.sdist]
exclude = [
"/.github",
"/docs",
]

[tool.hatch.build.targets.wheel]
packages = ["src/labone"]

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
"pycapnp",
"pytest_asyncio",
]

# Temporary solution until pycapnp has release its new version
[tool.hatch.envs.default.env-vars]
PIP_EXTRA_INDEX_URL = "https://docs.zhinst.com/pypi/"

[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = [
"- coverage combine",
"coverage report",
"coverage html",
]
cov = [
"test-cov",
"cov-report",
]

[[tool.hatch.envs.all.matrix]]
python = ["3.8", "3.9", "3.10", "3.11"]

[tool.hatch.envs.lint]
detached = true
dependencies = [
"black>=23.1.0",
"mypy>=1.0.0",
"ruff>=0.0.243",
]

[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:src/labone}"
style = [
"ruff {args:.}",
"black --check --diff {args:.}",
]
fmt = [
"black {args:.}",
"ruff --fix {args:.}",
"style",
]
all = [
"style",
"typing",
]

[tool.black]
line-length = 88
target-version = ['py39']
include = '\.pyi?$'
required-version = "23.7.0"
extend-exclude = '''
/(
| .mypy-cache
| .tox
| venv*
| docs
| build
| dist
)/
'''

[tool.isort]
profile = "black"
src_paths = ["src", "tests"]
target-version = ["py39"]

[tool.ruff]
target-version = "py39"
select = [
"ALL"
]
ignore = [
# Type annotation for self
"ANN101",
# Missing docstring in `__init__`
"D107",
]

[tool.ruff.pydocstyle]
convention = "google"

[tool.ruff.mccabe]
# Flag errors (`C901`) whenever the complexity level exceeds 15.
max-complexity = 15

[tool.ruff.isort]

[tool.ruff.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252", "ANN", "D", "SLF001", "PT011"]

[tool.coverage.run]
source_pkgs = ["labone"]
branch = true
parallel = true
omit = [
"src/labone/__about__.py",
]

[tool.coverage.paths]
labone = ["src/labone", "*/labone/src/labone"]

[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]

[[tool.mypy.overrides]]
module = "capnp.*"
ignore_missing_imports = true
6 changes: 5 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
hatch
hatch
pytest_asyncio

-i https://docs.zhinst.com/pypi/
pycapnp
3 changes: 2 additions & 1 deletion src/labone/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Official package for the Zurich Instruments LabOne software."""
from labone._version import __version__

__version__ == __version__
__all__ = ["__version__"]
1 change: 0 additions & 1 deletion src/labone/_version.py

This file was deleted.

6 changes: 6 additions & 0 deletions src/labone/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Subpackage for the core functionality of the LabOne API.
This subpackage manages the communication with the LabOne data server through
capnp. It encapsulates the low level logic of the capnp protocol and provides
a python only interface to the rest of the API.
"""
Loading

0 comments on commit 39d0639

Please sign in to comment.