-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Purpose Create the GS onboarding. # New Changes - Explain new changes # Testing - Pytest when working on developing the endpoints myself - Frontend build # Outstanding Changes - Add frontend testing
- Loading branch information
1 parent
e718cd3
commit 66e4d3d
Showing
63 changed files
with
4,228 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Purpose | ||
Completed the GS on-boarding task. Include a screenshot of the front-end of the application. | ||
|
||
# New Changes | ||
- Explain new changes | ||
|
||
# Testing | ||
- Explain tests that you ran to verify code functionality. | ||
- Any functions that can be unit-tested should include a unit test in the PR. Otherwise, explain why it cannot be unit-tested. | ||
|
||
# Outstanding Changes | ||
- If there are non-critical changes (i.e. additional features) that can be made to this feature in the future, indicate them here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Frontend Build | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
- name: Install dependencies for frontend | ||
run: | | ||
cd frontend | ||
npm ci | ||
- name: Build project | ||
run: | | ||
cd frontend | ||
npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Pytest | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
pytest: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
python-version: ['3.10'] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install -e . | ||
- name: Run pytest | ||
run: | | ||
python -m pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,213 @@ | ||
# GS-Onboarding | ||
Ground station onboarding for the firmware sub-team | ||
# GS Onboarding Challenge | ||
Welcome to Orbital's Ground Station Onboarding Challenge! Please visit this [Notion doc](https://www.notion.so/uworbital/Ground-Station-Onboarding-10f8a26d767780d7ae8de921d9782b77) for the challenge instructions. Remember to follow our style guide which is written below. | ||
|
||
## Python Style Guide | ||
|
||
- We will be following the Python language style guide [PEP8](https://peps.python.org/pep-0008/) | ||
- If there are any discrepancies between this style guide and PEP8, this style guide takes precedence. | ||
|
||
### Type Hinting Convention | ||
|
||
All function and method parameters (except for the `self` and `cls` parameters) and return signatures should be type hinted. | ||
|
||
```python | ||
def my_add(num1: int, num2: int) -> int: | ||
""" | ||
@brief Adds two numbers together | ||
@param num1 - The first number to add. | ||
@param num2 - The second number to add. | ||
@return Returns the sum of the two numbers. | ||
""" | ||
return num1 + num2 | ||
``` | ||
|
||
### Comments | ||
|
||
### Naming Conventions | ||
|
||
- `variable_names`, `field_names` and `function_constants` in snake_case | ||
- `_private_field_names`, and `_private_method_names()` in \_snake_case | ||
- `function_names()` and `method_names()` in snake_case | ||
- `CONSTANT_NAMES: Final` and `ENUM_OPTIONS` in CAPITAL_SNAKE_CASE for module and class constants (not for local constant) | ||
- `file_names` in snake_case | ||
- `ClassName` in PascalCase | ||
```python | ||
# For brevity, the class comments were removed but they should be in real code | ||
import dataclasses | ||
|
||
@dataclasses.dataclass | ||
class PointTwoDimension: | ||
x: int | ||
y: int | ||
|
||
class PointTwoDimension: | ||
def __init__(x: int, y: int): | ||
self.x = x | ||
self.y = y | ||
``` | ||
|
||
- `EnumName` in PascalCase | ||
|
||
```python | ||
import enum | ||
|
||
class ErrorCode(enum.Enum): | ||
SUCCESS = 0 | ||
INVALID_ARG = 1 | ||
|
||
# Accessing: | ||
ErrorCode.SUCCESS # <ErrorCode.SUCCESS: 0> | ||
ErrorCode.INVALID_ARG # <ErrorCode.INVALID_ARG: 1> | ||
``` | ||
|
||
#### Single Line Comments | ||
|
||
Variable and function names should be descriptive enough to understand even without comments. Comments are needed to describe any complicated logic. Use `#` for single-line comments. | ||
|
||
#### Function and Method Comments | ||
|
||
Function and method comments using `""" """` should exist below the function declaration. For methods, the `self` or `cls` parameter does not require a description. | ||
|
||
```python | ||
def my_add(num1: int, num2: int) -> int: | ||
""" | ||
@brief Adds two numbers together | ||
@param num1 - The first number to add. | ||
@param num2 - The second number to add. | ||
@return Returns the sum of the two numbers. | ||
""" | ||
return num1 + num2 | ||
``` | ||
|
||
```python | ||
def increase_x(self, count: int) -> None: | ||
""" | ||
@brief Increases the x attribute by the count. | ||
@param count - Count to increase the x attribute by. | ||
""" | ||
self.x += count | ||
``` | ||
|
||
#### File Header Comments | ||
|
||
File comments are not required | ||
|
||
#### Class Comments | ||
|
||
- Class comments should exist after the class definition | ||
- Provide a brief description given class purpose | ||
- Provide a section in the class comment listing the attributes, their type and purpose | ||
- Enum class comments do not require listing the attributes | ||
|
||
```python | ||
class PointTwoDimension: | ||
""" | ||
@brief Class for storing a 2D point | ||
@attribute x (int) - x coordinate of the point | ||
@attribute y (int) - y coordinate of the point | ||
""" | ||
|
||
def __init__(x: int, y: int): | ||
self.x = x | ||
self.y = y | ||
|
||
@dataclasses.dataclass | ||
class PointTwoDimension: | ||
""" | ||
@brief Class for storing a 2D point | ||
@attribute x (int) - x coordinate of the point | ||
@attribute y (int) - y coordinate of the point | ||
""" | ||
|
||
x: int | ||
y: int | ||
``` | ||
```python | ||
import enum | ||
|
||
# No comments required | ||
class ErrorCode(enum.Enum): | ||
""" | ||
@brief Enum for the error codes | ||
""" | ||
|
||
SUCCESS = 0 | ||
INVALID_ARG = 1 | ||
``` | ||
|
||
### Imports | ||
|
||
#### Grouping Imports | ||
|
||
Handled by pre-commit | ||
|
||
#### Notes about imports | ||
|
||
- Imports should only be used at the top of the file (no function or scoped imports) | ||
- Only modules should be imported | ||
|
||
```python | ||
# module1 contains very_long_module_name and function foo and variable var. | ||
# very_long_module_name contains bar | ||
|
||
# Yes: | ||
from module1 import very_long_module_name as module2 # Casting to shorter name | ||
import module1 | ||
|
||
module1.foo() | ||
module1.var | ||
module2.bar() | ||
|
||
# No: | ||
from module1.very_long_module_name import bar | ||
from module1 import foo, var | ||
|
||
foo() | ||
var | ||
bar() | ||
``` | ||
|
||
### Other Style Guide Points | ||
|
||
- Only imports, function, class, and constants declarations and the `if __name__ == '__main__'` should be in module scope | ||
- Entry point to a script or program should be through the `main` function | ||
- Add a trailing comma after elements of a list, if you wish to make/preserve each element on a separate line | ||
|
||
## Typescript/React Style Guide | ||
|
||
### Comments | ||
|
||
#### Single Line Comments | ||
|
||
Variable and function names should be descriptive enough to understand even without comments. Comments are needed to describe any complicated logic. You may use `//` or `/* */` for single line comments. | ||
|
||
#### Function Comments | ||
|
||
Function comments should follow the format shown below: | ||
```typescript | ||
/** | ||
* @brief Adds two numbers together | ||
* | ||
* @param num1 - The first number to add. | ||
* @param num2 - The second number to add. | ||
* @return Returns the sum of the two numbers. | ||
*/ | ||
function addNumbers(num1: number, num2: number): number { | ||
return num1 + num2; | ||
} | ||
``` | ||
|
||
#### File Header Comments | ||
|
||
- File comments are not required | ||
|
||
### ****Naming and typing conventions**** | ||
|
||
- `variableNames` in camelCase | ||
- `functionNames()` in camelCase | ||
- `CONSTANT_NAME` in CAPITAL_SNAKE_CASE | ||
- `file_names` in snake_case | ||
- `ClassName` and `ComponentName` in PascalCase |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from contextlib import asynccontextmanager | ||
from datetime import datetime | ||
from fastapi import FastAPI | ||
from sqlmodel import SQLModel, Session, select | ||
from backend.data.data_models import MainCommand | ||
from backend.data.engine import get_db | ||
from backend.data.mock_data import commands, main_commands | ||
from backend.utils.logging import logger_setup | ||
from backend.utils.time import to_unix_time | ||
|
||
|
||
def create_startup(session: Session) -> None: | ||
logger_setup() | ||
SQLModel.metadata.create_all(session.connection()) | ||
default_time = "2024-01-01T00:00:00" | ||
default_datetime = datetime.strptime(default_time, "%Y-%m-%dT%H:%M:%S") | ||
unix_time = to_unix_time(default_datetime) | ||
# Setup the db with mock data | ||
query = select(MainCommand).limit(1) # Check if the db is empty | ||
result = session.exec(query).first() | ||
if result is None: | ||
session.add_all(main_commands()) | ||
session.commit() | ||
session.add_all(commands(unix_time)) | ||
session.commit() | ||
|
||
|
||
@asynccontextmanager | ||
async def lifespan(_: FastAPI): | ||
"""Lifecycle event for the FastAPI app.""" | ||
create_startup(get_db()) | ||
yield | ||
print("Closing lifespan") |
Empty file.
Oops, something went wrong.