You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Purpose
Closes#321
# Warning: Breaking Changes
- All GS members will need to install PostgreSQL by following the
instructions in the `POSTGRESQL_SETUP.md` to run the backend
- Dropping support for using Windows as the development environment. Use
WSL instead if you are on Windows. See in the instructions in the
`README.md`. Make sure to install Ubuntu 22 as the distro of choice as
Ubuntu 24 has issues with installing Python packages in editable mode.
# New Changes
- Implement database schema for non auth related tables
- Switch the pytest workflow runner to use only Ubuntu
- Remove Docker setup instructions from the README as it is was unused
and there doesn't make sense to spend the effort to maintain it.
- Add PostgreSQL setup instructions
- Add database configuration files
- Create tests for database tables
- Create `MainCommands` get endpoint under the
`/api/v1/mcc/main-commands/` path
- Add some data for the `MainCommands`
- Make schemas, tables and data for `MainCommands` generate
automatically. The database must be created manually
- Fix minor README issues
# Testing
- Create unit tests for all tables
- Test the MainCommands get endpoint manually:

- Validate that the MainCommands exist in the database:

# Outstanding Changes
- Add auth related tables once we determine how to setup auth
- Improve the table tests to test data validation and more complex
relations.
- Improve the configuration files. This will be handled by #335
- Add loguru to SQLModel logger. This will be handled by #380
- Pull `MainCommands` and `MainTelemetry` from a configuration file and
have it synced with the OBC
- Add data validation for `MainCommands` table. This will be handled by
#356
- Determine what `subtype` for packets means. This is an CSDC
requirement but we can easily add this to the database later.
- Make `Commands.params` match with `MainCommands.params`
- Make `Telemetry.value` match with `MainTelemetry.params`
- Split up the README into separate READMEs for GS and Firmware where
instructions and data doesn't overlap
- Add test for `MainCommand` get endpoint
Copy file name to clipboardExpand all lines: README.md
+22-48Lines changed: 22 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,49 +41,8 @@ Download Code Composer Studio (CCS): https://www.ti.com/tool/CCSTUDIO. This will
41
41
42
42
Download UniFlash here: https://www.ti.com/tool/UNIFLASH#downloads. This will be used for flashing the RM46.
43
43
44
-
#### Docker Development Environment
45
-
46
-
It's **highly recommended** that you set up your development environment using Docker and VSCode, especially if you're new to software development. If you follow the instructions in this section, you can skip the **Windows/MacOS/Linux** sections. If you know what you're doing, feel free to set up your dev environment however you like using the instructions in the **Windows/MacOS/Linux** sections for reference. However, there may be a lack of support from other leads/members who don't use the same setup.
47
-
48
-
##### Docker Desktop Installation & Configuration
49
-
50
-
1. Install Docker Desktop App from [this link](https://www.docker.com/products/docker-desktop/)
51
-
- You can choose to sign-up/create an account but it's not required. You can also skip the "Tell-us about what you do" section.
52
-
2. Open Docker Desktop and click on `Dev Environments` from the side-panel
53
-
- Click on create on `Create +` in the top-right corner.
54
-
3. Setting up the repo
55
-
- Name the Environment as desired
56
-
- For the `Choose source` option, select `Local directory` and then select the `OBC-firmware` repository folder that you cloned earlier.
57
-
- Click `Continue`
58
-
- Once the container is created, you should be able to open the container in VSCode. If you have VSCode, you can press `Open in VSCode`. If you don't have VSCode, you can get it here: https://code.visualstudio.com/download
59
-
60
-
##### Installing Dependencies
61
-
62
-
Once you open the docker instance, open a terminal in VSCode and run the following commands. The dollar sign in your terminal should be prefaced by something like this: `root ➜ /com.docker.devenvironments.code (main ✗)`.
63
-
64
-
This command opens a terminal in VSCode: `` Ctrl + Shift + ` ``
curl -fsSL https://deno.land/install.sh | sh # Deno is required for pre-commit
72
-
pre-commit install
73
-
```
74
-
75
-
##### Testing The Container Build
76
-
77
-
To test whether your Dev environment has been set up correctly run the commands in the **Building** section. The OBC firmware and test builds should pass. All tests should succeed.
78
-
79
-
**Note**: The docker container uses pre-configured git (one added to the original OS path by the user). So you should be able to pull and push to the OBC repo as necessary.
80
-
81
-
**Tip**: Use the `git config --list` command on the VsCode terminal to confirm your git info.
82
-
83
44
#### **Windows**
84
45
85
-
Skip this section if you set up a Docker development environment.
Run the following command dependant on your setup.
15
+
If you have Windows, install WSL. See the instructions in the top level [README.md](../../README.md)
16
+
17
+
### Linux/WSL
18
+
19
+
```sh
20
+
sudo apt update
21
+
sudo apt install postgresql-16
22
+
```
23
+
24
+
### MacOS
25
+
26
+
```sh
27
+
brew install postgresql@16
28
+
brew services start postgresql
29
+
```
30
+
31
+
**[Back to top](#table-of-contents)**
32
+
33
+
## Database Setup
34
+
35
+
Run `sudo -u postgres psql --version` to check that it was installed properly. It should print that major version is 16.
36
+
37
+
Below are the commands to setup PostgreSQL for the ground station
38
+
```sh
39
+
sudo -u postgres psql # Connect to the PostgreSQL CLI
40
+
CREATE USER username WITH PASSWORD 'password' SUPERUSER;# Change username to your user on the machine and password to a strong password
41
+
# Log out of this session by pressing Ctrl + D
42
+
```
43
+
Log back in by running `psql` if username you created above matches the current user, you don't need to log in.
44
+
Otherwise, you will need to run `psql -U username` and then enter the password created above to proceed.
45
+
```sh
46
+
CREATE DATABASE gs;# gs database
47
+
\c gs;# Connect to the gs database
48
+
```
49
+
50
+
**[Back to top](#table-of-contents)**
51
+
52
+
## Environment Variable Setup
53
+
54
+
Find the `gs/backend/config/template.env` and create a copy of it in the same directory with the name `.env`
55
+
Inside your newly created `.env` file, put your username and password created above inside the quotes for `GS_DATABASE_USER` and `GS_DATABASE_PASSWORD` respectively.
56
+
57
+
In the end your `.env` file, should look like this:
58
+
```sh
59
+
GS_DATABASE_USER="username"# replace username with your created username
60
+
GS_DATABASE_PASSWORD="password"# replace password with your created password above
61
+
GS_DATABASE_LOCATION="localhost"# Change this if using a remote server
62
+
GS_DATABASE_PORT="5432"# Default PostgreSQL port. Change if needed
63
+
GS_DATABASE_NAME="gs"# Name of the database. NOTE: Make sure to create this manually before running the backend of the first time
64
+
```
65
+
66
+
Note: You can choose to remove the first to lines of the `.env` that start with \# as those lines are comments.
67
+
68
+
Now, you can start the backend as by running `fastapi dev gs/backend/main.py` from the top level directory to run in development mode.
69
+
70
+
**[Back to top](#table-of-contents)**
71
+
72
+
## Sources
73
+
74
+
-[How to Install and Setup PostgreSQL on Ubuntu 20.04 | Step-by-Step](https://www.cherryservers.com/blog/how-to-install-and-setup-postgresql-server-on-ubuntu-20-04)
75
+
-[Install and configure PostgreSQL](https://documentation.ubuntu.com/server/how-to/databases/install-postgresql/index.html)
76
+
-[How To Install PostgreSQL on Ubuntu 20.04 \[Quickstart\]](https://www.digitalocean.com/community/tutorials/how-to-install-postgresql-on-ubuntu-20-04-quickstart)
0 commit comments