Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 12 additions & 13 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,28 @@ 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: Install system dependencies
run: sudo apt-get install -y libmariadb-dev
- 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: |
hf auth login --token ${{ secrets.WADAS_OFFICIAL_HUGGINGF_AUTH }} --add-to-git-credential
source .venv/bin/activate
pip install huggingface_hub[cli]
huggingface-cli login --token ${{ secrets.WADAS_OFFICIAL_HUGGINGF_AUTH }}
- 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
Expand Down
19 changes: 6 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Binary file modified requirements.txt
Binary file not shown.
2 changes: 1 addition & 1 deletion wadas/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
2 changes: 2 additions & 0 deletions wadas/conda_env_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,3 +43,4 @@ dependencies:
- wadas-runtime==0.2.6
- opencv-python==4.10.0.84
- shapely==2.0.7
- setuptools>=65
4 changes: 4 additions & 0 deletions wadas/domain/actuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
}
)

Expand Down
18 changes: 17 additions & 1 deletion wadas/domain/actuator_server_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -201,9 +205,21 @@ 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)

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():
Expand Down
10 changes: 10 additions & 0 deletions wadas/domain/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions wadas/domain/db_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down