-
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.
MRG: Merge pull request #69 from aerosense-ai/feature/multiple-node-s…
…upport Support multiple nodes
- Loading branch information
Showing
52 changed files
with
3,330 additions
and
1,481 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 @@ | ||
.zsh_history |
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,40 @@ | ||
# A useful base repository based on ms devcontainer but with a bunch of fixes | ||
# and useful installs (geo tools are unnecessary for this project, but all the other tweaks are helpful) | ||
FROM windpioneers/gdal-python:familiar-catshark-gdal-2.4.1-python-3.9-dev | ||
|
||
# Tell zsh where you want to store history | ||
# We leave you to decide, but if you put this into a folder that's been mapped | ||
# into the container, then history will persist over container rebuilds :) | ||
# | ||
# !!!IMPORTANT!!! | ||
# Make sure your .zsh_history file is NOT committed into your repository, as it can contain | ||
# sensitive information. So in this case, you should add | ||
# .devcontainer/.zsh_history | ||
# to your .gitignore file. | ||
# | ||
ENV HISTFILE="/workspaces/data-gateway/.devcontainer/.zsh_history" | ||
|
||
# Switch to vscode user | ||
USER vscode | ||
WORKDIR /workspaces/data-gateway | ||
|
||
# Install the rust toolchain and give permission for all users to use it | ||
ENV RUST_INSTALL_DIR=/home/vscode/.rust | ||
ENV RUSTUP_HOME="${RUST_INSTALL_DIR}/rustup" | ||
ENV CARGO_HOME="${RUST_INSTALL_DIR}/cargo" | ||
RUN mkdir -p ${RUSTUP_HOME} && \ | ||
mkdir -p ${CARGO_HOME} | ||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y | ||
ENV PATH="${CARGO_HOME}/bin:${PATH}" | ||
RUN chmod -R ugo+rwx ${RUST_INSTALL_DIR} | ||
|
||
# Install poetry | ||
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python | ||
ENV PATH "/home/vscode/.poetry/bin:$PATH" | ||
RUN poetry config virtualenvs.create false | ||
|
||
# Install python dependencies. Note that poetry installs any root packages by default, | ||
# But this is not available at this stage of caching dependencies. So we do a dependency-only install here | ||
# to cache the dependencies, then a full poetry install post-create to install any root packages. | ||
COPY pyproject.toml poetry.lock ./ | ||
RUN poetry install --no-ansi --no-interaction --no-root |
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,84 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/python-3 | ||
{ | ||
"name": "Data-Gateway Devcontainer", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": ".." | ||
}, | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"austin.mode": "Wall time", | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true, | ||
"esbonio.server.enabled": true, | ||
"esbonio.sphinx.confDir": "${workspaceFolder}/docs/source", | ||
"jupyter.widgetScriptSources": ["jsdelivr.com", "unpkg.com"], | ||
"prettier.prettierPath": "/usr/local/prettier", | ||
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", | ||
"python.formatting.blackPath": "/usr/local/py-utils/bin/black", | ||
"python.formatting.provider": "black", | ||
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", | ||
"python.languageServer": "Pylance", | ||
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit", | ||
"python.linting.enabled": true, | ||
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", | ||
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", | ||
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", | ||
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", | ||
// Line length to match black settings | ||
// Disabling specific messages: | ||
// - To find the details do: /usr/local/py-utils/bin/pylint --list-msgs | ||
// - Disable missing-module-docstring (C0114) because we don't document modules routinely, just their members | ||
// - Disable invalid-name (C0103) because pylint thinks that eg 'x', 'df', 'np' are invalid due to their lengths | ||
"python.linting.pylintArgs": [ | ||
"--max-line-length=120", | ||
"--disable=missing-module-docstring,invalid-name" | ||
], | ||
"python.linting.pylintEnabled": true, | ||
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint", | ||
"python.pythonPath": "/usr/local/bin/python", | ||
// Scrolling the editor is a nice idea but it doesn't work: always out of sync and impossible to manage | ||
"restructuredtext.preview.scrollEditorWithPreview": false, | ||
"restructuredtext.preview.scrollPreviewWithEditor": false, | ||
"restructuredtext.linter.doc8.extraArgs": ["--max-line-length 180"], | ||
"terminal.integrated.defaultProfile.linux": "zsh" | ||
}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"bungcip.better-toml", | ||
"[email protected]", | ||
"irongeek.vscode-env", | ||
"lextudio.restructuredtext", | ||
"me-dutour-mathieu.vscode-github-actions", | ||
"mikestead.dotenv", | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"ms-toolsai.jupyter", | ||
"ms-toolsai.jupyter-renderers", | ||
"ms-toolsai.jupyter-keymap", | ||
"ms-vsliveshare.vsliveshare", | ||
"p403n1x87.austin-vscode", | ||
"ritwickdey.liveserver", | ||
"trond-snekvik.simple-rst" | ||
], | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
"forwardPorts": [80, 443, 5000, 7045, 7046, 7047, 7048, 7049, 8000, 8080], | ||
|
||
// Poetry install *with* the root, which can't be cached in the docker layers (see dockerfile) | ||
"postCreateCommand": "poetry install && pre-commit install && pre-commit install -t commit-msg", | ||
|
||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "vscode", | ||
|
||
// Allow ptrace based debuggers (like austin) to work in the container | ||
"runArgs": [ | ||
"--env-file", | ||
"${localWorkspaceFolder}/.env", | ||
"--cap-add=SYS_PTRACE", | ||
"--security-opt", | ||
"seccomp=unconfined" | ||
] | ||
} |
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,9 @@ | ||
**/.DS_Store | ||
.coverage | ||
.devcontainer/ | ||
.env | ||
.pytest_cache/ | ||
.tox/ | ||
.venv/ | ||
.vscode/ | ||
*.wg.conf |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: balena | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
balena-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/[email protected] | ||
- uses: theaccordance/[email protected] | ||
with: | ||
api-token: ${{secrets.BALENA_API_TOKEN}} | ||
application-name: ${{secrets.BALENA_APPLICATION_NAME}} |
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,68 @@ | ||
name: gcloud-deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- test | ||
|
||
jobs: | ||
deploy: | ||
permissions: | ||
contents: "read" | ||
id-token: "write" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get prefix (test- or nothing for production) | ||
id: prefix | ||
run: | | ||
if [ "${{ github.ref }}" = "main" ]; then | ||
echo "::set-output name=name_prefix::" | ||
else | ||
echo "::set-output name=name_prefix::test-" | ||
fi | ||
- id: auth | ||
uses: google-github-actions/auth@v0 | ||
with: | ||
workload_identity_provider: "projects/885434704038/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider" | ||
service_account: "[email protected]" | ||
|
||
- id: deploy-add-sensor-type | ||
uses: google-github-actions/deploy-cloud-functions@v0 | ||
with: | ||
name: ${{ steps.prefix.outputs.name_prefix }}add-sensor-type | ||
description: Allows addition of a new sensor type whose values will be accepted into the database | ||
entry_point: add_sensor_type | ||
runtime: python39 | ||
region: europe-west6 | ||
env_vars: BIG_QUERY_DATASET_NAME=${{ steps.prefix.outputs.name_prefix }}greta,COMPUTE_PROVIDER=GOOGLE_CLOUD_FUNCTION,DESTINATION_PROJECT_NAME=aerosense-twined | ||
source_dir: cloud_functions | ||
|
||
- id: deploy-create-installation | ||
uses: google-github-actions/deploy-cloud-functions@v0 | ||
with: | ||
name: ${{ steps.prefix.outputs.name_prefix }}create-installation | ||
description: Allows creation of a new installation | ||
entry_point: create_installation | ||
runtime: python39 | ||
region: europe-west6 | ||
env_vars: BIG_QUERY_DATASET_NAME=${{ steps.prefix.outputs.name_prefix }}greta,COMPUTE_PROVIDER=GOOGLE_CLOUD_FUNCTION,DESTINATION_PROJECT_NAME=aerosense-twined | ||
source_dir: cloud_functions | ||
|
||
- id: deploy-ingress-eu | ||
uses: google-github-actions/deploy-cloud-functions@v0 | ||
with: | ||
name: ${{ steps.prefix.outputs.name_prefix }}ingress-eu | ||
entry_point: upload_window | ||
runtime: python39 | ||
region: europe-west6 | ||
memory: 1GB | ||
env_vars: BIG_QUERY_DATASET_NAME=${{ steps.prefix.outputs.name_prefix }}greta,COMPUTE_PROVIDER=GOOGLE_CLOUD_FUNCTION,DESTINATION_PROJECT_NAME=aerosense-twined,DESTINATION_BUCKET_NAME=data-gateway-processed-data,SOURCE_PROJECT_NAME=aerosense-twined | ||
source_dir: cloud_functions | ||
event_trigger_type: google.storage.object.finalize | ||
event_trigger_resource: projects/_/buckets/${{ steps.prefix.outputs.name_prefix }}aerosense-ingress-eu | ||
event_trigger_service: storage.googleapis.com |
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 |
---|---|---|
|
@@ -105,3 +105,9 @@ ENV/ | |
|
||
.DS_store | ||
.pytest_cache | ||
|
||
# Wireguard credentials | ||
*.wg.conf | ||
|
||
# VSCode local settings | ||
.vscode |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# base-image for python on any machine using a template variable, | ||
# see more about dockerfile templates here: https://www.balena.io/docs/learn/develop/dockerfile/ | ||
FROM balenalib/%%BALENA_MACHINE_NAME%%-debian-python:3.8-bullseye-run | ||
|
||
# Install git for development purposes | ||
RUN install_packages git | ||
|
||
# Set our working directory | ||
RUN mkdir -p /usr/aerosense/data-gateway | ||
WORKDIR /usr/aerosense/data-gateway | ||
|
||
# Copy requirements.txt first for better cache on later pushes | ||
COPY requirements-pi.txt requirements-pi.txt | ||
|
||
# Install python deps on the resin.io build server | ||
RUN pip install -r requirements-pi.txt | ||
|
||
# Copy and install the project, to source the gateway CLI | ||
COPY . ./ | ||
RUN pip install . | ||
|
||
# Enable udevd so that plugged dynamic hardware devices show up in our container. | ||
ENV UDEV=1 | ||
|
||
# Keep the container alive after start, so we can ssh in and use the gateway | ||
CMD ["sleep", "infinity"] |
Oops, something went wrong.