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

44 - adding pyproject precommit #45

Merged
merged 28 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2b1e5f4
adds pyproject.toml #44,
mxochicale Mar 31, 2024
e7bb329
adds `.pre-commit-config.yaml` #44
mxochicale Mar 31, 2024
698434f
remove yml for VE #44
mxochicale Mar 31, 2024
1754f60
run `pre-commit run -a` with trailing-whitespace #44
mxochicale Mar 31, 2024
00be532
run `pre-commit run -a` with end-of-file-fixer #44
mxochicale Mar 31, 2024
36e3856
excluding multiple patters using regex operator and adds check-yaml a…
mxochicale Mar 31, 2024
dee6ba4
run `pre-commit run -a` with local hook isort #44
mxochicale Mar 31, 2024
92c28bb
run `pre-commit run -a` with local hook black #44
mxochicale Mar 31, 2024
763ee3d
run `pre-commit run -a` with local hook codespell and corrections #44
mxochicale Mar 31, 2024
62a5409
run `pre-commit run -a` with local pylint and excluded paths #44
mxochicale Apr 1, 2024
e4ac894
run `pre-commit run -a` with pylint solving long lines #44
mxochicale Apr 1, 2024
d2b3022
run `pre-commit run -a` with pylint solving `Missing module docstrin…
mxochicale Apr 1, 2024
6346631
run `pre-commit run -a` with pylint solving `snake_case naming style…
mxochicale Apr 1, 2024
13ea8bd
run `pre-commit run -a` with pylint solving all linting issues of tes…
mxochicale Apr 1, 2024
996aee4
run `pre-commit run -a` with pylint solving `snake_case naming style…
mxochicale Apr 1, 2024
db049c2
adds tests/.pylintc to address E1101: MODULEi cv2 > code rated at 9.…
mxochicale Apr 1, 2024
7bbddbc
run `pre-commit run -a` with pylint solving C0209: Formatting a regul…
mxochicale Apr 1, 2024
bbb6dab
run `pre-commit run -a` with pylint solving W0612: Unused variable `r…
mxochicale Apr 1, 2024
c9ddb57
tidies up pyproject with optional deps and main README #44
mxochicale Apr 1, 2024
2acfbea
adds .github/workflows/pre-commit.yml #44
mxochicale Apr 1, 2024
8243422
adds https://github.com/PyCQA/isort in pre-commit-yml #44
mxochicale Apr 1, 2024
763d3f0
adds - repo: https://github.com/psf/black in pre-commit-yml #44
mxochicale Apr 1, 2024
b25edca
tyding up - repo: https://github.com/psf/black in pre-commit-yml #44
mxochicale Apr 1, 2024
402c5c8
reverse to pass https://github.com/PyCQA/isort in pre-commit-yml #44
mxochicale Apr 1, 2024
c9402b5
reverse to pass locally pre-commit-yml #44
mxochicale Apr 1, 2024
d784cdc
commeting branches to not trigger ci for pre-commit #44
mxochicale Apr 1, 2024
0998b5f
commenting branches to not trigger ci for pre-commit #44
mxochicale Apr 1, 2024
0a91a3e
commenting branches and pr to not trigger ci for pre-commit #44
mxochicale Apr 1, 2024
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
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pre-commit

#on:
# pull_request:
# push:
# branches:
# - main
# - 44-pyproject-precommit

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@
## others
*.ipynb_checkpoints
**/__pycache__
*.egg-info
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: 'data/.*|docs/.*'
exclude_types: [markdown]
- id: end-of-file-fixer
exclude: 'data/.*|docs/.*'
exclude_types: [markdown]
- id: check-yaml
- id: check-added-large-files
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args:
[
"--rcfile=tests/.pylintrc" #Link to config file > `pylint --generate-rcfile > tests/.pylintrc`
]
exclude: 'data/.*|docs/.*|notebooks/.*|dependencies/.*|src/sentient/utils/.*|src/sentient/sensor_fusion/.*'
- id: black
name: black
entry: black
language: system
types: [python]
- id: isort
name: isort
entry: isort
language: system
types: [python]
- id: codespell
name: codespell
description: Checks for common misspellings in text files.
entry: codespell
language: python
types: [ text ]
exclude: 'data/.*|docs/.*|notebooks/.*|dependencies/.*'
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![GitHub Discussions](https://img.shields.io/github/discussions/mxochicale/sentient)](https://github.com/mxochicale/sentient/discussions)

The aim of this repository is to develop S.E.N.T.I.E.N.T. libray (Sensor Enhanced Network Technology Integrating Evolving Neural Tools).
The aim of this repository is to develop S.E.N.T.I.E.N.T. library (Sensor Enhanced Network Technology Integrating Evolving Neural Tools).
`sentient` library includes multi-sensor data methods using SOTA (State-Of-The-Art) AI models for skills assessment in surgery, sports, and robotics.
Hence, this repository contains sentient's related material with dependencies, sample-data, scripts, unit tests, docs and references.

Expand All @@ -16,16 +16,44 @@ You can run [notebooks](sentient/data_analysis) for data analysis.
See AI-enabled [models](sentient/models) (work in progress).
If interested in cada collection, please see [sensor fusion](sentient/sensor_fusion) and [video_devices](sentient/video_devices).

## Installation
```
conda create -n "sentientVE" python=3.10 pip
conda activate sentientVE
pip install --editable . # Install the package in editable mode
pip install .[test]
pip install .[learning]
#pip uninstall sentient
#conda deactivate
#conda remove -n sentientVE --all

```
## Pre-commmit
```
conda activate sentientVE
pre-commit run -a
```

### Testing sensor data
Just test default local camera id 0.
```
mamba activate sentientVE
mamba activate sentientbasicVE
export PYTHONPATH=$HOME/repositories/sentient
cd $HOME/repositories/sentient
conda activate sentientVE
#export PYTHONPATH=$HOME/repositories/sentient
#export PYTHONPATH="${PYTHONPATH}:$HOME/repositories/sentient"
python -m pytest -v -s tests/
python -m pytest -v -s tests/test_video_capture.py::test_simple_list_of_available_video_devices
python -m pytest -v -s tests/test_video_capture.py::test_capture_video
```

## Notebooks
```
conda activate sentientVE
cd $HOME/repositories/sentient/notebooks
#export PYTHONPATH="${PYTHONPATH}:$HOME/repositories/sentient"
jupyter notebook --browser=firefox
```

## Clone repository
* Generate your SSH keys as suggested [here](https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) (or [here](https://github.com/mxochicale/tools/blob/main/github/SSH.md))
* Clone the repository by typing (or copying) the following line in a terminal at your selected path in your machine:
Expand Down
34 changes: 0 additions & 34 deletions dependencies/no-gpu-ve.yml

This file was deleted.

1 change: 0 additions & 1 deletion dependencies/openzen/cpp_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ set_target_properties(${CMAKE_PROJECT_NAME}17 PROPERTIES CXX_STANDARD 17)

target_link_libraries(${CMAKE_PROJECT_NAME}14 OpenZen::OpenZen)
target_link_libraries(${CMAKE_PROJECT_NAME}17 OpenZen::OpenZen)

3 changes: 1 addition & 2 deletions dependencies/openzen/cpp_examples/example-cpp14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int main(int argc, char* argv[])
<< "\t y = " << event.second.data.imuData.r[1]
<< "\t z = " << event.second.data.imuData.r[2] << std::endl;

std::cout << "> Quaternions \t\t\t q0 = " << event.second.data.imuData.q[0]
std::cout << "> Quaternions \t\t\t q0 = " << event.second.data.imuData.q[0]
<< "\t q1 = " << event.second.data.imuData.q[1]
<< "\t q2 = " << event.second.data.imuData.q[2]
<< "\t q3 = " << event.second.data.imuData.q[3] << std::endl;
Expand Down Expand Up @@ -144,4 +144,3 @@ int main(int argc, char* argv[])
std::cout << "OpenZen client closed successfully" << std::endl;
return 0;
}

5 changes: 2 additions & 3 deletions dependencies/openzen/cpp_examples/example-cpp17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main(int argc, char* argv[])
std::cout << "> Acceleration [g] \t\t x = " << event->data.imuData.a[0]
<< "\t y = " << event->data.imuData.a[1]
<< "\t z = " << event->data.imuData.a[2] << std::endl;

// depending on sensor, gyro data is outputted to g1, g2 or both
// read more on https://lpresearch.bitbucket.io/openzen/latest/getting_started.html#id1
std::cout << "> Gyro 1 [deg/seg] \t\t x = " << event->data.imuData.g1[0]
Expand All @@ -89,7 +89,7 @@ int main(int argc, char* argv[])
<< "\t y = " << event->data.imuData.r[1]
<< "\t z = " << event->data.imuData.r[2] << std::endl;

std::cout << "> Quaternions [nounit] \t\t q0 = " << event->data.imuData.q[0]
std::cout << "> Quaternions [nounit] \t\t q0 = " << event->data.imuData.q[0]
<< "\t q1 = " << event->data.imuData.q[1]
<< "\t q2 = " << event->data.imuData.q[2]
<< "\t q3 = " << event->data.imuData.q[3] << std::endl;
Expand Down Expand Up @@ -139,4 +139,3 @@ int main(int argc, char* argv[])
std::cout << "Sensor connection closed" << std::endl;
return 0;
}

54 changes: 30 additions & 24 deletions dependencies/openzen/hello-multi-sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
error = client.list_sensors_async()

#############################################################
print(f'Connecting to sensors')
print(f"Connecting to sensors")
error, sensor_s7e = client.obtain_sensor_by_name("Bluetooth", s0MACid)
if not error == openzen.ZenError.NoError:
print("Error connecting to sensor", s0MACid)
Expand All @@ -50,11 +50,11 @@
print("Error connecting to sensor", s2MACid)
sys.exit(1)
imu_s5b = sensor_s5b.get_any_component_of_type(openzen.component_type_imu)
print(f'Sensors connected')
print(f"Sensors connected")


# Set stream frequency
streamFreq = 100 # Hz
streamFreq = 100 # Hz

error = imu_s7e.set_int32_property(openzen.ZenImuProperty.SamplingRate, streamFreq)
error, freq = imu_s7e.get_int32_property(openzen.ZenImuProperty.SamplingRate)
Expand All @@ -71,7 +71,7 @@

##############################################################
print(f"-----------------------")
print(f'Sensor sync')
print(f"Sensor sync")
imu_s7e.execute_property(openzen.ZenImuProperty.StartSensorSync)
imu_s95.execute_property(openzen.ZenImuProperty.StartSensorSync)
imu_s5b.execute_property(openzen.ZenImuProperty.StartSensorSync)
Expand All @@ -89,44 +89,50 @@
imu_s7e.execute_property(openzen.ZenImuProperty.StopSensorSync)
imu_s95.execute_property(openzen.ZenImuProperty.StopSensorSync)
imu_s5b.execute_property(openzen.ZenImuProperty.StopSensorSync)
print(f'Sensor sync completed ')
print(f"Sensor sync completed ")

total_number_of_samples = streamFreq * 10 # Collect 10 seconds of data
total_number_of_samples = streamFreq * 10 # Collect 10 seconds of data
imu_s7e_data_count = 0
imu_s5b_data_count = 0
imu_s95_data_count = 0

while True:
zenEvent = client.wait_for_next_event()

print('\n -------------------- \n ')
print("\n -------------------- \n ")

print('imu_s7e > ')
if zenEvent.event_type == openzen.ZenEventType.ImuData and \
zenEvent.sensor == imu_s7e.sensor and \
zenEvent.component.handle == imu_s7e.component.handle:
print("imu_s7e > ")
if (
zenEvent.event_type == openzen.ZenEventType.ImuData
and zenEvent.sensor == imu_s7e.sensor
and zenEvent.component.handle == imu_s7e.component.handle
):
imu_data = zenEvent.data.imu_data

imu_s7e_data_count = imu_s7e_data_count + 1
print(f' imu_s7e {imu_s7e_data_count}, {imu_data.timestamp}, {imu_data.q}')

print('imu_s5b > ')
if zenEvent.event_type == openzen.ZenEventType.ImuData and \
zenEvent.sensor == imu_s5b.sensor and \
zenEvent.component.handle == imu_s5b.component.handle:
print(f" imu_s7e {imu_s7e_data_count}, {imu_data.timestamp}, {imu_data.q}")

print("imu_s5b > ")
if (
zenEvent.event_type == openzen.ZenEventType.ImuData
and zenEvent.sensor == imu_s5b.sensor
and zenEvent.component.handle == imu_s5b.component.handle
):
imu_data = zenEvent.data.imu_data

imu_s5b_data_count = imu_s5b_data_count + 1
print(f' imu_s5b {imu_s5b_data_count}, {imu_data.timestamp}, {imu_data.q}')

print('imu_s95 > ')
if zenEvent.event_type == openzen.ZenEventType.ImuData and \
zenEvent.sensor == imu_s95.sensor and \
zenEvent.component.handle == imu_s95.component.handle:
print(f" imu_s5b {imu_s5b_data_count}, {imu_data.timestamp}, {imu_data.q}")

print("imu_s95 > ")
if (
zenEvent.event_type == openzen.ZenEventType.ImuData
and zenEvent.sensor == imu_s95.sensor
and zenEvent.component.handle == imu_s95.component.handle
):
imu_data = zenEvent.data.imu_data

imu_s95_data_count = imu_s95_data_count + 1
print(f' imu_s95 {imu_s95_data_count}, {imu_data.timestamp}, {imu_data.q}')
print(f" imu_s95 {imu_s95_data_count}, {imu_data.timestamp}, {imu_data.q}")

# Check data count of 1 sensor as loop termination condition for easier comparison
if imu_s5b_data_count >= total_number_of_samples:
Expand Down
Loading