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

Release 0.2 #87

Closed
wants to merge 65 commits into from
Closed
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
ea862f6
update version
jonathanhliu21 Dec 23, 2021
0116980
Update develop branch
jonathanhliu21 Dec 25, 2021
c9f1c59
update develop branch
jonathanhliu21 Dec 31, 2021
fe29c50
add logging
jonathanhliu21 Jan 1, 2022
a0f52f5
update docs
jonathanhliu21 Jan 1, 2022
fbcf532
update changelog
jonathanhliu21 Jan 1, 2022
49b99db
format using black
jonathanhliu21 Jan 1, 2022
15444f7
Update develop
jonathanhliu21 Jan 2, 2022
8978cb9
rename run_prod to run
jonathanhliu21 Jan 2, 2022
4cb6957
update docs
jonathanhliu21 Jan 2, 2022
ebfff37
update changelog
jonathanhliu21 Jan 2, 2022
9ee5e50
Update develop branch
jonathanhliu21 Jan 2, 2022
d387697
update develop
jonathanhliu21 Jan 3, 2022
c5ff134
fix double logging
jonathanhliu21 Jan 3, 2022
41f02e4
fix 502 logging in dev server
jonathanhliu21 Jan 3, 2022
933e21a
fix type annotations
jonathanhliu21 Feb 19, 2022
d824d35
add new server design
jonathanhliu21 Feb 19, 2022
2d868b8
remove baseconnection
jonathanhliu21 Feb 19, 2022
794320f
fix issues with server
jonathanhliu21 Feb 19, 2022
335983c
add exception
jonathanhliu21 Feb 19, 2022
920a6fb
add tests for new methods and ConnectionRoutes
jonathanhliu21 Feb 19, 2022
0f963ca
update tested on table
jonathanhliu21 Feb 19, 2022
bb4e809
add delay universally for all OSes
jonathanhliu21 Feb 19, 2022
e738723
update docs
jonathanhliu21 Feb 19, 2022
6dccc8f
add returns to functions
jonathanhliu21 Feb 20, 2022
fe21417
add supported methods
jonathanhliu21 Feb 20, 2022
7a86f77
add http method tests
jonathanhliu21 Feb 20, 2022
a171cce
change wording
jonathanhliu21 Feb 21, 2022
c92ab87
check if connected already
jonathanhliu21 Feb 21, 2022
c2d7313
implement V1 API
jonathanhliu21 Feb 21, 2022
af4ac84
update CLI
jonathanhliu21 Feb 21, 2022
98ee9d6
explicitly check for not connected
jonathanhliu21 Feb 21, 2022
37943fa
update readme
jonathanhliu21 Feb 21, 2022
7f390c4
add catch all 404s
jonathanhliu21 Feb 21, 2022
1e28f28
add data to response when sending
jonathanhliu21 Feb 21, 2022
de07ec6
delete testing readmes
jonathanhliu21 Feb 21, 2022
63aedef
update test structure
jonathanhliu21 Feb 21, 2022
2ec794a
fix cmp_version
jonathanhliu21 Feb 21, 2022
019b59a
update contributing
jonathanhliu21 Feb 21, 2022
2b89a4f
fix testing scripts
jonathanhliu21 Feb 21, 2022
ed407a6
add check for server
jonathanhliu21 Feb 21, 2022
1d5c574
add more detailed help
jonathanhliu21 Feb 22, 2022
c837f36
add send_for_response
jonathanhliu21 Feb 22, 2022
f2f834e
update docs
jonathanhliu21 Feb 22, 2022
76091dd
add data response
jonathanhliu21 Feb 22, 2022
abe9591
add docs for main CLI
jonathanhliu21 Feb 22, 2022
e7f3a1a
add active tests
jonathanhliu21 Feb 22, 2022
b72b4e8
add v1 docs
jonathanhliu21 Feb 23, 2022
d52b309
check if handler is instance of connection routes
jonathanhliu21 Feb 23, 2022
1168445
add V1 API test
jonathanhliu21 Feb 23, 2022
0afccc8
update changelog
jonathanhliu21 Feb 23, 2022
9caf93f
add __name__ == "__main__"
jonathanhliu21 Feb 23, 2022
9e3a3a3
move availability 0 test above other availbiility test
jonathanhliu21 Feb 23, 2022
729b916
add status code
jonathanhliu21 Feb 23, 2022
815ea49
fix annotations
jonathanhliu21 Feb 23, 2022
b131ae9
add black to requirements
jonathanhliu21 Feb 23, 2022
f778411
format test files
jonathanhliu21 Feb 23, 2022
c9b20aa
make mypy happy
jonathanhliu21 Feb 23, 2022
f438acb
add typing issue
jonathanhliu21 Feb 24, 2022
56400b8
add tox
jonathanhliu21 Feb 24, 2022
9007c99
add typing reminder
jonathanhliu21 Feb 24, 2022
0fa8243
add new workflow
jonathanhliu21 Feb 24, 2022
c45c53b
update python command
jonathanhliu21 Feb 24, 2022
3cf2f06
update changelog
jonathanhliu21 Feb 24, 2022
471b4b0
Merge pull request #96 from jonyboi396825/develop
jonathanhliu21 Feb 24, 2022
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
38 changes: 0 additions & 38 deletions .github/workflows/run-pytest-develop-win.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/run-pytest-develop.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/run-pytest-pr-win.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/run-pytest-pr.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/run-pytest-push.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Tests
on:
push:
branches:
- develop
- master
paths-ignore:
- 'docs/**'
- '*.md'
- '*.rst'
pull_request:
branches:
- develop
- master
paths-ignore:
- 'docs/**'
- '*.md'
- '*.rst'
jobs:
tests:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {name: Linux, python: '3.10', os: ubuntu-latest, tox: passive}
- {name: Windows, python: '3.10', os: windows-latest, tox: passive}
- {name: Mac, python: '3.10', os: macos-latest, tox: passive}
- {name: '3.9', python: '3.9', os: ubuntu-latest, tox: passive}
- {name: '3.8', python: '3.8', os: ubuntu-latest, tox: passive}
- {name: '3.7', python: '3.7', os: ubuntu-latest, tox: passive}
- {name: '3.6', python: '3.6', os: ubuntu-latest, tox: passive}
- {name: Typing, python: '3.10', os: ubuntu-latest, tox: typing}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- name: update pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- run: pip install tox
- run: tox -e ${{ matrix.tox }}
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# 0.2 Beta Release 0

Previous version: 0.1.*

## IMPORTANT: BREAKING changes from previous version:

- Deleted `Builtins` because of compatibility issues

## Changes from previous version

- Added logging using Python's `logging` module and also added logging to file when disconnects happen, addressing [#73](https://github.com/jonyboi396825/COM-Server/issues/73)
- CLI now runs production server instead of development server by default, and now recommending production server, addressing [#97](https://github.com/jonyboi396825/COM-Server/issues/97)
- Updated `__repr__` for `Connection`
- Added new `ConnectionRoutes` class for adding resources which gives users more flexibility over their Flask app object than the old `RestApiHandler` (check docs for more details), addressing [#104](https://github.com/jonyboi396825/COM-Server/issues/104)
- Added `start_app`, `start_conns`, `add_resources`, and `disconnect_conns` as helper functions to `ConnectionRoutes`, which allow it to start the connections and run the server.
- `ConnectionRoutes` explicitly responds with `500 Internal Server Error` rather than relying on exceptions from the `Connection` class when the connection is disconnected.
- Added the new V1 API which uses `ConnectionRoutes` and follows RESTful principles more than the V0 API, addressing [#86](https://github.com/jonyboi396825/COM-Server/issues/86)
- Fixed type annotations such that it passes `mypy` static typing checks
- Added `tox`, making CI with Github Actions easier
- CLI now uses `click` instead of `docopt` and serves V1 API
- Deleted CLI docs because help option is now better
- Updated all `Getting Started` and homepages to use `ConnectionRoutes`

# 0.1.4

Previous version: 0.1.3
Expand Down
19 changes: 14 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,27 @@ Launch the server:

Replace "<baud>" and "<serport>" with the baud and serial port of your serial device.

Use pytest:
Use the testing scripts:
```sh
> pytest -vv
> python3 tests/passive_test.py -vv
> python3 tests/active_test.py -vv
```

Make sure that all tests pass.

Some tests need the `com_server` command to be run or the Arduino to be plugged in. Make sure the listed command is run and and Arduino is plugged in to make sure that every test passes and none of them are skipped.
Some tests need the `com_server` command to be run or the Arduino to be plugged in. Make sure to run both commands above and also ensure that the Arduino is plugged in.

When writing tests, use the `pytest` library, and make them as specific as possible, testing a specific part of what you are making.
When writing tests, use the `pytest` library, and make them as specific as possible, testing a specific part of what you are making. Tests that do not require a serial port or a server should go into the `tests/passive` directory, and tests that do require an Arduino should go into the `tests/active` directory.

I am also open to those who write new tests to already existing code, especially ones that can test if the methods of the `BaseConnection` and `Connection` classes are behaving properly.
I am also open to those who write new tests to already existing code.

## Typing:

If writing code in the `src/com_server` directory, please use `mypy` to check static typing by running:

```sh
> mypy -p com_server
```

### Formatting:

Expand Down
47 changes: 20 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,15 @@ COM-Server is a Python library and a local web server that hosts an API locally

The serial communication uses [pyserial](https://pyserial.readthedocs.io/en/latest/pyserial.html) as its back-end and the server uses [flask-restful](https://flask-restful.readthedocs.io/en/latest/quickstart.html) and [Flask](https://flask.palletsprojects.com/en/2.0.x/). Reading their documentations may help with developing with COM-Server.

**NOTE**: COM-Server has only been tested on:
Operating systems:
**NOTE**: COM-Server is mainly tested on a Raspberry Pi connected to an Arduino UNO running Raspberry Pi OS Buster with Python 3.7.3. It has also been tested on:

- Ubuntu 20.04 (Focal Fossa)
- Raspberry Pi OS 10 (Buster)
- Mac OS 10.15.x (Catalina)
- Mac OS 11.6 (Big Sur)
- Windows 10
OS | Version
---- | ----
Linux | Ubuntu 20.04 with Python 3.8.10
MacOS | Big Sur with Python 3.8.9
Windows | Windows 10 with Python 3.9.7, Windows 11 with Python 3.9.7

Python versions:

- Python 3.7.2
- Python 3.7.3
- Python 3.8.10
- Python 3.9.7
- Python 3.10.0

Serial ports:

- Arduino UNO
- Arduino Nano
It is likely that this library will not work for non-USB ports.

## Recommended use
COM-Server is **not** meant to be used like a normal JSON API, even though it uses Flask and Flask-restful. If there are many different devices accessing the endpoints at the same time, data will be backed up, since the serial communication is relatively slow and things cannot be sent to the serial device at the same time.
Expand All @@ -53,19 +41,24 @@ For beta releases, use the `--pre` option:

## Quickstart

The examples below will start an API server that interacts with the port at http://0.0.0.0:8080

```py
# launches a development server on http://0.0.0.0:8080
# launches a server on http://0.0.0.0:8080

import com_server
from com_server.api import Builtins
from com_server import Connection, ConnectionRoutes, start_app
from com_server.api import V1
from flask import Flask
from flask_restful import Api

conn = com_server.Connection(<baud>, "<serport>")
handler = com_server.RestApiHandler(conn)
Builtins(handler)
app = Flask(__name__)
api = Api(app)

handler.run_dev(host="0.0.0.0", port=8080)
conn = Connection(<baud>, "<serport>")
handler = ConnectionRoutes(conn)
V1(handler)

conn.disconnect()
start_app(app, api, handler)
```
Replace "&lt;serport&gt;" and "&lt;baud&gt;" with the serial port and baud rate.

Expand Down
Loading