Skip to content

Commit 7d4110c

Browse files
mingzezhlbojo006
andauthored
refactor!: new code structure and switched to fastapi (#1)
* Initial Setup, cleaning needed before merging to main * refactor!: better code structure * note things are current broken need to fix them later --------- Co-authored-by: lbojo006 <luisbojorquezgoal@gmail.com>
1 parent 26e7621 commit 7d4110c

20 files changed

Lines changed: 6228 additions & 1 deletion

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__pycache__/
2+
3+
.venv/
4+
.mypy_cache/
5+
.pytest_cache/
6+
.ruff_cache/
7+
8+
daqserver.egg-info/

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.14

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,53 @@
11
# daqserver
2-
The main DAQ server repo
2+
3+
The main DAQ server repo.
4+
5+
## Running this project
6+
7+
1. Download the command [`uv`](https://docs.astral.sh/uv/getting-started/installation/) to your computer
8+
2. Download [`git`](https://git-scm.com/install/) command to your computer
9+
3. Clone the project `git clone https://github.com/Highlander-Space-Program/daqserver.git`
10+
4. Get into the source code `cd daqserver`
11+
5. Run the project `uv run server`
12+
13+
You don't need to download any Python for this, `uv` will download the right
14+
version and install all of the packages for you.
15+
16+
## Development
17+
18+
If you are going to add a new package to the python code, use `uv add
19+
package-name`. When you are committing code, I recommend following the [git
20+
commit conventions](https://www.conventionalcommits.org/en/v1.0.0/). For this
21+
project, I don't want anyone to directly push code to the `main` branch, unless
22+
you are doing a quick bugfix or fixing a typo. What you are going to do is push
23+
your local branch to this remote repository, and then create a pull request
24+
that is going to merge into the `main` branch. The DAQ lead or DAQ SE will look
25+
over your code in the pull request. If it is good, we will merge your code to
26+
the `main` branch, and if it is not good, we will ask you to make some changes.
27+
The idea here is that we want to keep `main` branch stable and not breaking.
28+
This means that you need to always create a new branch whenever you started
29+
working on your code.
30+
31+
## I am confused
32+
33+
This section here shows you how to navigate and use the codebase. If you have
34+
trouble with creating a pull request or how to use `git` you should try looking
35+
for a quick Youtube Tutorial or try asking ChatGPT, and then learn how to solve
36+
ur `git` problem, so you won't have to deal with it again later in the future.
37+
38+
Under some directories like [`scripts`](./scripts) and [`server`](./server),
39+
you may find another `README.md` file. Inside of these `README.md` files, you
40+
will find guides and descriptions that will help you with navigating around the
41+
codebase. Don't afraid to ping the DAQ lead or the DAQ SE for help. Trying to
42+
figure out how to work with a new codebase yourself is difficult. When you are
43+
assigned a task for this project, you are expected to know a little bit of
44+
Python and also a little bit of `git`. Please don't ever use `git push --force`
45+
or `git push --force-with-lease` if you have no idea what you are doing.
46+
47+
For those of you who already know a little bit about Python, it's a good idea
48+
to follow the [`PEP-8`](https://peps.python.org/pep-0008/) styling guide when
49+
adding your code to the project. If you want to challenge yourself a bit more
50+
(and I would be really happy if you do), try to make sure that everything you
51+
wrote is [type hinted](https://peps.python.org/pep-0484/) and tested through
52+
`pytest` (yes this means I would like you to write some unit tests for your
53+
code whenever possible).

labjack_channels.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[
2+
{
3+
"Type": "AIN",
4+
"AIN": "AIN48",
5+
"NegativeAIN": "AIN56",
6+
"SensorType": "LoadCell",
7+
"Differential": true,
8+
"Bank": null,
9+
"CB37_Index": null
10+
},
11+
{
12+
"Type": "AIN",
13+
"AIN": "AIN50",
14+
"SensorType": "Pressure",
15+
"Differential": false,
16+
"Bank": "X3",
17+
"CB37_Index": 2
18+
},
19+
{
20+
"Type": "AIN",
21+
"AIN": "AIN52",
22+
"NegativeAIN": "AIN60",
23+
"SensorType": "Thermocouple",
24+
"Differential": true,
25+
"Bank": "X3",
26+
"CB37_Index": 4
27+
}
28+
]

pyproject.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[project]
2+
name = "daqserver"
3+
version = "0.1.0"
4+
description = "The big daq server"
5+
readme = "README.md"
6+
requires-python = ">=3.14"
7+
dependencies = [
8+
"fastapi[standard]>=0.135.1",
9+
"labjack-ljm>=1.23.0",
10+
"rich>=14.3.3",
11+
"websockets>=16.0",
12+
]
13+
14+
[tool.uv]
15+
package = true
16+
17+
[project.scripts]
18+
server = "server.__main__:main"
19+
20+
[tool.setuptools.packages.find]
21+
include = ["server*"]
22+
23+
[tool.pyright]
24+
venvPath = "."
25+
venv = ".venv"
26+
27+
[tool.ruff]
28+
line-length = 82
29+
30+
[tool.ruff.format]
31+
docstring-code-format = true
32+
docstring-code-line-length = 80
33+
34+
# [tool.ruff.lint]
35+
# # Add the `line-too-long` rule to the enforced rule set.
36+
# extend-select = ["E501"]
37+
38+
[dependency-groups]
39+
dev = [
40+
"mypy>=1.19.1",
41+
"pathspec>=1.0.4",
42+
"pytest>=9.0.2",
43+
]

scripts/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Scripts
2+
3+
<!-- filetree start -->
4+
5+
```text
6+
daqserver
7+
├── scripts (You are here)
8+
└── server
9+
├── streaming
10+
└── web
11+
├── static
12+
│ ├── css
13+
│ └── js
14+
└── templates
15+
```
16+
17+
<!-- filetree end -->
18+
19+
## About scripts
20+
21+
This directory contains all of the scripts that are going to help you
22+
throughout the development of this project. If you have other scripts that you
23+
want to add to here, feel free to do so. Make sure you have documented the
24+
scripts that you have added at the top of the script file so people know what's
25+
going on in the script and how to use it.
26+
27+
Having the script be written in the Python language is preferred. Running the
28+
Python scripts is usually just `uv run scripts/script_name.py`, and this
29+
ensures cross platform compatibility (People using MacOS might not be able to
30+
use a `batch` script). If you have a good reason to use batch like creating
31+
some sort of installer for Windows users then feel free to use batch.
32+
33+
## How to use the scripts
34+
35+
If the script is written in Python (files that ends with `.py`), then you can
36+
should be able to run it using `uv run scripts/script_name.py` where you have
37+
to replace the `script_name` with the actual script's name. Please open the
38+
script file that you are running for documentation about how to use it.

0 commit comments

Comments
 (0)