From fe67595dc148d9259d3c6629d32d4398473b16fc Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 11:49:26 +0100 Subject: [PATCH 01/13] temperature and humidity fields now added for battery status --- wadas/_version.py | 2 +- wadas/domain/actuator.py | 4 ++++ wadas/domain/actuator_server_app.py | 10 +++++++++- wadas/domain/database.py | 10 ++++++++++ wadas/domain/db_model.py | 2 ++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/wadas/_version.py b/wadas/_version.py index 0cb32e65..f9fc846f 100644 --- a/wadas/_version.py +++ b/wadas/_version.py @@ -17,5 +17,5 @@ # Date: 2024-08-14 # Description: module to keep track of WADAS version -__version__ = "v1.0.0.a5" +__version__ = "v1.0.0.a6" __dbversion__ = __version__ diff --git a/wadas/domain/actuator.py b/wadas/domain/actuator.py index 163bd0fd..a9988733 100644 --- a/wadas/domain/actuator.py +++ b/wadas/domain/actuator.py @@ -76,6 +76,8 @@ def from_json(cls, s: str) -> "Command": class ActuatorBatteryStatus: actuator_id: str voltage: float + temperature: float + humidity: float time_stamp: datetime.datetime = field(default_factory=datetime.datetime.now) def to_json(self) -> str: @@ -84,6 +86,8 @@ def to_json(self) -> str: "actuator_id": self.actuator_id, "voltage": self.voltage, "time_stamp": self.time_stamp.isoformat(), + "temperature": self.temperature, + "humidity": self.humidity, } ) diff --git a/wadas/domain/actuator_server_app.py b/wadas/domain/actuator_server_app.py index 33f67a6c..12c6d6c7 100644 --- a/wadas/domain/actuator_server_app.py +++ b/wadas/domain/actuator_server_app.py @@ -193,6 +193,10 @@ async def receive_battery_status(actuator_id: str, payload: dict = Body(...)): if voltage is None: raise HTTPException(status_code=400, detail="Missing 'volt' in payload") + # We accept the possibility that temperature or humidity are null if sensor is not plugged + temperature = payload.get("payload", {}).get("temperature") + humidity = payload.get("payload", {}).get("humidity") + # Timestamp set by server ts = datetime.datetime.now() @@ -201,9 +205,13 @@ async def receive_battery_status(actuator_id: str, payload: dict = Body(...)): actuator_id=actuator_id, voltage=voltage, time_stamp=ts, + temperature=temperature, + humidity=humidity, ) actuator.battery_status = battery_status - logger.info("Received actuator %s battery status: %s", actuator_id, voltage) + logger.info( + "Received actuator %s battery status: %s", actuator_id, voltage, temperature, humidity + ) # Persist in DB if db := DataBase.get_enabled_db(): diff --git a/wadas/domain/database.py b/wadas/domain/database.py index 7c3b9c12..54e96bc0 100644 --- a/wadas/domain/database.py +++ b/wadas/domain/database.py @@ -499,6 +499,14 @@ def update_db_version(self): """ ) ) + elif cur_db_version <= "v1.0.0.a5": + DataBase.run_query( + text("ALTER TABLE actuator_battery_status ADD COLUMN temperature FLOAT NULL;") + ) + DataBase.run_query( + text("ALTER TABLE actuator_battery_status ADD COLUMN humidity FLOAT NULL;") + ) + DataBase.run_query(text(f"UPDATE db_metadata SET version='{__dbversion__}';")) logger.info("Database updated from %s to %s", cur_db_version, __dbversion__) except Exception: @@ -950,6 +958,8 @@ def domain_to_orm(domain_object, foreign_key=None): actuator_id=foreign_key[0], time_stamp=domain_object.time_stamp, voltage=domain_object.voltage, + temperature=domain_object.temperature, + humidity=domain_object.humidity, ) elif isinstance(domain_object, ActuatorTemperatureStatus): return ORMActuatorTemperature( diff --git a/wadas/domain/db_model.py b/wadas/domain/db_model.py index 54ddc698..1785af72 100644 --- a/wadas/domain/db_model.py +++ b/wadas/domain/db_model.py @@ -208,6 +208,8 @@ class ActuatorBatteryStatus(Base): actuator_id = Column(Integer, ForeignKey("actuators.id"), primary_key=True, nullable=False) time_stamp = Column(MySQLDATETIME6(timezone=True), primary_key=True, nullable=False) voltage = Column(Float) + temperature = Column(Float, nullable=True) + humidity = Column(Float, nullable=True) class ActuatorTemperatureStatus(Base): From a8fe92aea1c2e8a1ed85ebcc10249a1d5db88c70 Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 12:05:39 +0100 Subject: [PATCH 02/13] Replaced flake8 with Ruff in pre-commit hooks --- .pre-commit-config.yaml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70eb3600..a030763a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,19 +23,12 @@ repos: rev: v1.0.0 hooks: - id: check-json5 -- repo: https://github.com/PyCQA/flake8 - rev: 7.1.1 - hooks: - - id: flake8 - additional_dependencies: [ - 'flake8-blind-except', - 'flake8-bugbear', - 'flake8-comprehensions', - 'flake8-implicit-str-concat', - 'flake8-logging-format', - 'pydocstyle>=5.0.0', - ] - exclude: ^wadas/ui/.*|demo/.* +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.5 + hooks: + - id: ruff + args: [--no-fix] + exclude: ^wadas/ui/.*|demo/.* - repo: https://github.com/pycqa/isort rev: 5.13.2 hooks: From 43aa92abaf40e0fe66d9c4573b6f15f0dd22dada Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 12:36:21 +0100 Subject: [PATCH 03/13] fixed logging format --- wadas/domain/actuator_server_app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wadas/domain/actuator_server_app.py b/wadas/domain/actuator_server_app.py index 12c6d6c7..11d5ee89 100644 --- a/wadas/domain/actuator_server_app.py +++ b/wadas/domain/actuator_server_app.py @@ -210,7 +210,11 @@ async def receive_battery_status(actuator_id: str, payload: dict = Body(...)): ) actuator.battery_status = battery_status logger.info( - "Received actuator %s battery status: %s", actuator_id, voltage, temperature, humidity + "Received actuator %s battery status: %s V, temperature: %s °, humidity: %s %%", + actuator_id, + voltage, + temperature, + humidity, ) # Persist in DB From 12c8c352a1a3c051cdd6b00700e506449c72705d Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 12:41:01 +0100 Subject: [PATCH 04/13] handle absence of temperature and humidity from battery monitor --- wadas/domain/actuator_server_app.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/wadas/domain/actuator_server_app.py b/wadas/domain/actuator_server_app.py index 11d5ee89..95e6d50f 100644 --- a/wadas/domain/actuator_server_app.py +++ b/wadas/domain/actuator_server_app.py @@ -209,13 +209,17 @@ async def receive_battery_status(actuator_id: str, payload: dict = Body(...)): humidity=humidity, ) actuator.battery_status = battery_status - logger.info( - "Received actuator %s battery status: %s V, temperature: %s °, humidity: %s %%", - actuator_id, - voltage, - temperature, - humidity, - ) + + if temperature and humidity: + logger.info( + "Received actuator %s battery status: %s V, temperature: %s °, humidity: %s %%", + actuator_id, + voltage, + temperature, + humidity, + ) + else: + logger.info("Received actuator %s battery status: %s V.", actuator_id, voltage) # Persist in DB if db := DataBase.get_enabled_db(): From 54696e3b512e6a59624afe31d493439faad4f4bb Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 18:45:35 +0100 Subject: [PATCH 05/13] pristined setuptools dependency in conda env --- requirements.txt | Bin 5330 -> 5354 bytes wadas/conda_env_setup.yml | 1 + 2 files changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 0e4644bd4d9d86ec1fc31e6a595c2e58dc03a853..0d07a886d32cc4d9730eebd9c1783b6140a4b122 100644 GIT binary patch delta 30 icmcbl`ATy`2ESk`LkUAELjjP?2f`eN;?0Ttg{%OVL Date: Sun, 22 Feb 2026 18:59:41 +0100 Subject: [PATCH 06/13] fix setuptools dependency --- requirements.txt | Bin 5354 -> 5362 bytes wadas/conda_env_setup.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0d07a886d32cc4d9730eebd9c1783b6140a4b122..d162fc5c982dbffcbe031af37266d4bc1d814405 100644 GIT binary patch delta 20 bcmaE*`AKs_6+gQjgDry@gX!i<{z6s&OC|;e delta 12 TcmeyQ`ATy`760ZY{sLA2Cxrze diff --git a/wadas/conda_env_setup.yml b/wadas/conda_env_setup.yml index 9c81a482..1f6b110e 100644 --- a/wadas/conda_env_setup.yml +++ b/wadas/conda_env_setup.yml @@ -29,6 +29,7 @@ dependencies: - openssl=3.4.0 - cryptography=42.0.8 - pyopenssl=24.2.1 + - setuptools>=65 - pip: - cv2-enumerate-cameras==1.1.15 - intel-npu-acceleration-library==1.4.0 @@ -41,5 +42,4 @@ dependencies: - ray==2.43.0 - wadas-runtime==0.2.6 - opencv-python==4.10.0.84 - - setuptools - shapely==2.0.7 From 1055de74264a8b68dd97300b3d96480ded0fe81c Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 19:09:51 +0100 Subject: [PATCH 07/13] attempt to fix setuptools failure in github job --- wadas/conda_env_setup.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/wadas/conda_env_setup.yml b/wadas/conda_env_setup.yml index 1f6b110e..1d428520 100644 --- a/wadas/conda_env_setup.yml +++ b/wadas/conda_env_setup.yml @@ -31,6 +31,7 @@ dependencies: - pyopenssl=24.2.1 - setuptools>=65 - pip: + - setuptools>=65 - cv2-enumerate-cameras==1.1.15 - intel-npu-acceleration-library==1.4.0 - pyside6==6.8.0.2 From ae7d937ca76298a4bba62be4956f16715c255973 Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 19:27:05 +0100 Subject: [PATCH 08/13] Add step to fix setuptools version in workflow fix setuptools dependency in test execution --- .github/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4390d5cd..2888cabb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,6 +29,8 @@ jobs: - run: | conda info conda list + - name: Fix setuptools + run: pip install --force-reinstall setuptools>=65 - name: Login to Hugging Face run: | hf auth login --token ${{ secrets.WADAS_OFFICIAL_HUGGINGF_AUTH }} --add-to-git-credential From b28bf1be08d1575a31e867d0da0fcb642d34d952 Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 19:42:40 +0100 Subject: [PATCH 09/13] Moved from conda to venv to fis setuptools dependency issue --- .github/workflows/test.yaml | 22 ++++++++-------------- wadas/conda_env_setup.yml | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2888cabb..f6616b85 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,31 +11,25 @@ on: jobs: build: runs-on: ubuntu-latest - defaults: - run: - shell: bash -el {0} steps: - uses: actions/checkout@v3 - name: Set up Python 3.10 uses: actions/setup-python@v3 with: python-version: "3.10" - - name: Install conda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: WADAS - environment-file: wadas/conda_env_setup.yml - auto-activate-base: false - - run: | - conda info - conda list - - name: Fix setuptools - run: pip install --force-reinstall setuptools>=65 + - name: Create venv and install dependencies + run: | + python -m venv .venv + source .venv/bin/activate + pip install --upgrade pip + pip install -r requirements.txt - name: Login to Hugging Face run: | + source .venv/bin/activate hf auth login --token ${{ secrets.WADAS_OFFICIAL_HUGGINGF_AUTH }} --add-to-git-credential - name: Run tests run: | + source .venv/bin/activate python -m pytest test -sv --cov=. --cov-report=html # To enforce minimum coverage, uncomment the following line: # python -m pytest test -sv --cov=. --cov-report=html --cov-fail-under=80 diff --git a/wadas/conda_env_setup.yml b/wadas/conda_env_setup.yml index 1d428520..f3971ace 100644 --- a/wadas/conda_env_setup.yml +++ b/wadas/conda_env_setup.yml @@ -31,7 +31,6 @@ dependencies: - pyopenssl=24.2.1 - setuptools>=65 - pip: - - setuptools>=65 - cv2-enumerate-cameras==1.1.15 - intel-npu-acceleration-library==1.4.0 - pyside6==6.8.0.2 @@ -44,3 +43,4 @@ dependencies: - wadas-runtime==0.2.6 - opencv-python==4.10.0.84 - shapely==2.0.7 + - setuptools>=65 From 6e29abb0baf0965e3a0496551880e530ddea0b4c Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 19:46:22 +0100 Subject: [PATCH 10/13] fixed mariadb depemndencies for venv in workflow --- .github/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f6616b85..333bfc1c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -17,6 +17,8 @@ jobs: uses: actions/setup-python@v3 with: python-version: "3.10" + - name: Install system dependencies + run: sudo apt-get install -y libmariadb-dev - name: Create venv and install dependencies run: | python -m venv .venv From 6047c1ad28024f471caa88a9b5cfeadc7a92d63a Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 19:54:15 +0100 Subject: [PATCH 11/13] installed hf dependency --- .github/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 333bfc1c..1413f285 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -28,6 +28,7 @@ jobs: - name: Login to Hugging Face run: | source .venv/bin/activate + pip install huggingface_hub[cli] hf auth login --token ${{ secrets.WADAS_OFFICIAL_HUGGINGF_AUTH }} --add-to-git-credential - name: Run tests run: | From d4cfc4e06f1e69a986373ecc28dbdb0e36c59870 Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 20:06:46 +0100 Subject: [PATCH 12/13] modified hf run in test workflow --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1413f285..7ecf1d80 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,7 +29,7 @@ jobs: run: | source .venv/bin/activate pip install huggingface_hub[cli] - hf auth login --token ${{ secrets.WADAS_OFFICIAL_HUGGINGF_AUTH }} --add-to-git-credential + python -m huggingface_hub login --token ${{ secrets.WADAS_OFFICIAL_HUGGINGF_AUTH }} - name: Run tests run: | source .venv/bin/activate From 827179818fbca395493bffa43b9eb2a5f0ff936c Mon Sep 17 00:00:00 2001 From: Stefano Dell'Osa Date: Sun, 22 Feb 2026 20:11:14 +0100 Subject: [PATCH 13/13] hf cli run in test workflow --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7ecf1d80..76e0d8d1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,7 +29,7 @@ jobs: run: | source .venv/bin/activate pip install huggingface_hub[cli] - python -m huggingface_hub login --token ${{ secrets.WADAS_OFFICIAL_HUGGINGF_AUTH }} + huggingface-cli login --token ${{ secrets.WADAS_OFFICIAL_HUGGINGF_AUTH }} - name: Run tests run: | source .venv/bin/activate