Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example and introduce FlowchemDeviceClients #99

Merged
merged 65 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
20b1c69
Rename example folder for ALC0315 example
dcambie Jul 3, 2023
1bc24cd
Refactor Zerconfig of devices
dcambie Jul 3, 2023
b07e34d
Avoid circular import loop
dcambie Jul 3, 2023
6d442f1
Add test for config parser
dcambie Jul 3, 2023
267c59a
BUGFIX
dcambie Jul 3, 2023
ed67c81
list device properties in list_flowchem_devices.py
dcambie Jul 3, 2023
1eb6fea
Do not include duplicate device info in the mDNS server but on http only
dcambie Jul 3, 2023
e14f611
Add basic per-device response page
dcambie Jul 3, 2023
d4501e9
Listen on all network interfaces as default
dcambie Jul 4, 2023
634fb0f
Add CI test on python 3.12
dcambie Jul 11, 2023
94ea64f
rename autodiscover.py tp device_finder.py
dcambie Jul 11, 2023
f1d682e
Remove useless run_create_server_from_file
dcambie Jul 11, 2023
1e1d381
Basic client implementation - device discovery
dcambie Jul 11, 2023
97128b2
Stub for FlowchemDeviceClient
dcambie Jul 11, 2023
8921e61
Fix mypy
dcambie Jul 11, 2023
d0f9dd2
Update GA depreacted options names
dcambie Jul 11, 2023
86b6e34
move vendored deps
dcambie Jul 12, 2023
635a96d
ruff add src location
dcambie Jul 12, 2023
1d27b80
Remove maintainers from DeviceInfo
dcambie Jul 12, 2023
79a74c2
rename metadata to more descriptive names
dcambie Jul 12, 2023
a363065
Allow multiple subclass for owl ontologies and minor cleanups
dcambie Jul 12, 2023
8eee42e
Appease mypy
dcambie Jul 12, 2023
dbb848b
pytest fixes
dcambie Jul 12, 2023
4f1211f
mypy
dcambie Jul 12, 2023
41f9661
cleanup server part
dcambie Jul 13, 2023
6df8841
missing rename from refactoring
dcambie Jul 13, 2023
458effb
simplify test for client
dcambie Jul 13, 2023
6c45fb0
mypy
dcambie Jul 13, 2023
44d09f4
fix pytest
dcambie Jul 13, 2023
ed0facf
deal with flaky tests
dcambie Jul 13, 2023
fde8f7e
Drop get_flowchem_device_by_name
dcambie Jul 13, 2023
ad4e543
Minor changes
dcambie Jul 13, 2023
5f2239e
Minor changes
dcambie Jul 13, 2023
98eb6e1
maybe not always an abstract method
dcambie Jul 13, 2023
924fe0b
Docstring improvements
dcambie Jul 13, 2023
1ba9559
New device syntax (#100)
dcambie Jul 13, 2023
c221329
Merge
dcambie Jul 13, 2023
179cf99
mypy
dcambie Jul 13, 2023
615a3e0
drop requirement for components in device
dcambie Jul 13, 2023
f76a73f
further streamlining in client use
dcambie Jul 13, 2023
fde1b1b
Fix timeout in GA
dcambie Jul 13, 2023
5732e01
mypy
dcambie Jul 13, 2023
ffd5dbe
Fix R2 pressure units
dcambie Jul 13, 2023
c80dd5c
clean run experiment
dcambie Jul 13, 2023
445614e
Minor changes
dcambie Jul 13, 2023
6b20442
Minor changes
dcambie Jul 13, 2023
16d1449
Minor changes
dcambie Jul 13, 2023
5f64e44
mypy
dcambie Jul 13, 2023
6b1c63d
minor refactoring
dcambie Jul 13, 2023
15d094f
Create codeql.yml (#101)
dcambie Jul 13, 2023
7cddad6
update ga actions
dcambie Jul 13, 2023
e538ac3
Merge remote-tracking branch 'origin/alc0315' into alc0315
dcambie Jul 13, 2023
afc5ed3
Device restructure (#103)
dcambie Aug 29, 2023
cf0845c
Update pydantic requirment
dcambie Aug 29, 2023
67404f7
Merge branch 'alc0315' of github.com:cambiegroup/flowchem into alc0315
dcambie Aug 29, 2023
abe82f6
bump readthedocs py version
dcambie Aug 30, 2023
d94a4f7
-examples
dcambie Aug 30, 2023
7fda350
Simplify pyproject.toml
dcambie Aug 30, 2023
76fbf7d
Add missing file
dcambie Sep 1, 2023
93b4916
minor changes
dcambie Sep 1, 2023
5190cfe
types
dcambie Sep 1, 2023
f2164e1
typo
dcambie Sep 1, 2023
9b10fe2
+ruff cache in gitignore
dcambie Sep 1, 2023
1085f14
Update config parser test
dcambie Sep 1, 2023
079af4c
Fix components url
dcambie Sep 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/deadpendency.yaml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '40 3 * * 2'

jobs:
analyze:
name: Analyze
runs-on: 'ubuntu-latest'
timeout-minutes: 360
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: 'python'

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:python"
6 changes: 3 additions & 3 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
skip_existing: true
repository-url: https://test.pypi.org/legacy/
skip-existing: true

- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref_name, 'v')
uses: pypa/gh-action-pypi-publish@release/v1

build-release-gh:
build-release-github:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
python-version: [
"3.11",
"3.12-dev",
]
operating-system:
- ubuntu-latest
- windows-latest
Expand All @@ -24,19 +28,19 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python 3.11
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: ${{ matrix.python-version }}

- name: Install flowchem
run: |
python -m pip install .[dev,types,test]
python -m pip install .[ci]
pip freeze

- name: Run mypy
run: |
mypy --check-untyped-defs --python-version 3.10 --ignore-missing-imports ./src
mypy --check-untyped-defs --python-version 3.11 --ignore-missing-imports ./src

- name: Run ruff
run: ruff .
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,4 @@ dmypy.json
.pyre/
/flowchem/devices/Vapourtec/commands.py
/src/flowchem/devices/knauer_hplc_nda.py
.ruff_cache
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: 2
build:
os: ubuntu-20.04
tools:
python: "3.10"
python: "3.11"

sphinx:
configuration: docs/conf.py
Expand Down
1 change: 1 addition & 0 deletions docs/_static/architecture_v1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 15 additions & 14 deletions docs/add_device/add_to_flowchem.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ either directly or with an intermediate `/flowchem/devices/weasley/__init__.py`
### Device configuration
Additional parameters needed for the device setup can be specified in the `__init__` method, if a default is provided
the parameter will also be optional in the device section in the configuration file.
In our case, the ExtentableEar has an optional length parameter, with a default value of "10 cm".
In our case, the ExtendableEar has an optional length parameter, with a default value of "10 cm".
To prevent ambiguities, all amounts with units should be provided as strings and parsed by the pint UnitRegistry
`flowchem.ureg`.
```python
Expand Down Expand Up @@ -120,7 +120,7 @@ For example, we can define three methods: one to start the recording, one to sto
The stop method will be responsible for returning the path of the file where the recording was saved.

```python
from flowchem.components.sensors.base_sensor import Sensor
from flowchem.components.sensors.sensor import Sensor


class Microphone(Sensor):
Expand Down Expand Up @@ -155,31 +155,32 @@ commands to our device and some metadata about our device:
```python
...
from flowchem.devices.weasley.extendable_ear_microphone import ExtendableEarMicrophone
from flowchem.devices.flowchem_device import FlowchemDevice, DeviceInfo, Person
from flowchem.devices.flowchem_device import FlowchemDevice
from flowchem.components.device_info import DeviceInfo, Person


class ExtendableEar(FlowchemDevice):
metadata = DeviceInfo(
authors=[Person(name="George Weasley", email="[email protected]"),
Person(name="Fred Weasley", email="[email protected]")],
maintainers=[Person(name="George Weasley", email="[email protected]")],
manufacturer="Weasley & Weasley",
model="Extendable Ear",
)
def __init__(self, name):
super().__init__(name)
self.device_info.manufacturer = "Weasley & Weasley",
self.device_info.authors = [Person(name="George Weasley", email="[email protected]"),
Person(name="Fred Weasley", email="[email protected]")]
self.device_info.model = "Extendable Ear"

...

def send_command(self, command):
print(command) # This is in place of actual communication with the device

def components(self):
return ExtendableEarMicrophone("microphone", self),

def components(self):
return ExtendableEarMicrophone("microphone", self),
```

Now if we run `flowchem ear.toml` again the server will start successfully and show the metadata info together with the
`start` and `stop` methods.

![](../add_device/extendable_ear1.png)
![](extendable_ear1.png)

However, executing start and stop will not execute any code.
For that we need to add some code in out `ExtendableEarMicrophone` to transform these calls into action.
Expand All @@ -202,7 +203,7 @@ class ExtendableEarMicrophone(Microphone):
If we run `flowchem ear.toml` once again we can now see the code in `ExtendableEar` being executed when the API
is called.

![](../add_device/extendable_ear2.png)
![](extendable_ear2.png)


Finally, if we want to support some additional feature off our device that go beyond those of the standard component,
Expand Down
2 changes: 1 addition & 1 deletion docs/api/elite11/api.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Havard Apparatus Elite11
# Harvard Apparatus Elite11
See the [how-to guide](../../devices/pumps/elite11.md) to configure an Elite11 object.

```{eval-rst}
Expand Down
2 changes: 1 addition & 1 deletion docs/api/icir/api.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MattlerToledo iCIR
# MettlerToledo iCIR

See the [how-to guide](../../devices/analytics/icir.md) to configure an IcIR object.

Expand Down
2 changes: 1 addition & 1 deletion docs/api/vici_valve/api.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Vici Valco Unviersal Valve Actuator
# Vici Valco Universal Valve Actuator
See the [how-to guide](../../devices/valves/vici_valve.md) to configure a ViciValve object.

```{eval-rst}
Expand Down
4 changes: 2 additions & 2 deletions docs/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Moreover, the source code in the `flowchem` packages is organized in:

* Create a branch for the feature you want to work on. Since the branch name will appear in the merge message, use a
sensible name.
For example, if you intend to add support for a new device type, called ExtendibleEar a good candidate
could be ‘add-extendible-ear-support’: `git checkout -b add-extendible-ear-support`
For example, if you intend to add support for a new device type, called ExtendableEar a good candidate
could be ‘add-extendable-ear-support’: `git checkout -b add-extendible-ear-support`

* Commit locally as you progress (`git add` and `git commit`).
Use a properly formatted commit message, and ideally write tests that fail before your change and pass afterward.
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In a typical scenario, flowchem:
<img src="./_static/architecture_v1.svg" alt="Flowchem software architecture (devices/config/server)" class="bg-primary mb-1" width="100%">

**Figure 1** Schematic representation of flowchem software architecture.
An heterogeneous collection of devices is physically connected to a control PC.
A heterogeneous collection of devices is physically connected to a control PC.
The configuration file in TOML format specifies the connection parameters for each device.
After running flowchem with that configuration, a web server is started to control each device via a single API.
:::
Expand Down
2 changes: 1 addition & 1 deletion docs/json2yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
import yaml

print(
yaml.dump(json.load(open(sys.argv[1])), default_flow_style=False, sort_keys=False)
yaml.dump(json.load(open(sys.argv[1])), default_flow_style=False, sort_keys=False),
)
6 changes: 3 additions & 3 deletions docs/learning/tutorial.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Introductory tutorial

Something something on how to write config
Something on how to write config

Something something on how to run server
Something on how to run server

Something something on how to consume the API
Something on how to consume the API with the clients or OpenAPI things
3 changes: 3 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Examples

This folder collects example of the use of flowchem devices.
28 changes: 0 additions & 28 deletions examples/autonomous_reaction_optimization/_hw_control.py

This file was deleted.

80 changes: 0 additions & 80 deletions examples/autonomous_reaction_optimization/main_loop.py

This file was deleted.

34 changes: 0 additions & 34 deletions examples/autonomous_reaction_optimization/plot/plot.py

This file was deleted.

Loading