Skip to content

Commit

Permalink
Merge pull request #46 from B-AROL-O/ci/update-super-linter
Browse files Browse the repository at this point in the history
ci: update super linter version (v5 -> v7)
  • Loading branch information
gmacario authored Oct 7, 2024
2 parents 528cca6 + f4e4ad9 commit 4e8c741
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .github/linters/.hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
ignored:
- DL3008
28 changes: 28 additions & 0 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"threshold": 10,
"reporters": [
"html",
"markdown"
],
"ignore": [
"**/node_modules/**",
"**/.git/**",
"**/.rbenv/**",
"**/.venv/**",
"**/report/**",
"**/megalinter-reports/**",
"**/hardis-report/**",
"**/*cache*/**",
"**/*.json",
"**/*.yaml",
"**/*.yml",
"**/*.md",
"**/*.html",
"**/*.xml",
"**/*.jpg",
"**/*.png",
"**/*.svg",
"**/*.zip",
"**/*.bin"
]
}
13 changes: 13 additions & 0 deletions .github/linters/.python-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[FORMAT]

# Maximum number of characters on a single line.
max-line-length=88

[DESIGN]

# Maximum number of attributes (methods/classes)
max-attributes=20

[MESSAGES CONTROL]

disable=C0114,W1514,C0103,R1710,R1720,R1705,C0116,E0401
9 changes: 7 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ name: Lint Code Base
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#

# Prevent writing with GH Actions token
permissions: read-all

#############################
# Start the job on all push #
#############################
Expand Down Expand Up @@ -48,13 +51,15 @@ jobs:
# Run Linter against code base #
################################
- name: Lint Code Base
uses: super-linter/super-linter/slim@v5
uses: super-linter/super-linter/slim@v7
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_JSON: false
VALIDATE_JSON_PRETTIER: false
VALIDATE_SHELL_SHFMT: false
VALIDATE_DOCKERFILE_HADOLINT: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Do not lint downloaded code - see https://github.com/github/super-linter
FILTER_REGEX_EXCLUDE: .*/download/.*|layout.html

# EOF
9 changes: 9 additions & 0 deletions code/oak-d-lite-module/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ RUN git clone https://github.com/luxonis/depthai.git depthai

RUN ./depthai/docker_dependencies.sh

RUN useradd -m depthai
USER depthai

RUN python3 ./depthai/install_requirements.py

WORKDIR /

COPY requirements.txt .

RUN pip3 install --no-cache-dir -r requirements.txt

HEALTHCHECK CMD curl -f http://localhost:9090/ || exit 1

CMD ["python3", "/oak-d-lite-module/vision_webserver.py"]
4 changes: 2 additions & 2 deletions code/oak-d-lite-module/vision_container.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

docker run --rm \
--privileged \
--name=oak-d-lite-server \
Expand All @@ -7,5 +8,4 @@ docker run --rm \
--device-cgroup-rule='c 189:* rmw' \
-p 9090:9090 \
-d \
depthai-freisa:latest \
python3 /oak-d-lite-module/vision_webserver.py
depthai-freisa:latest
37 changes: 18 additions & 19 deletions code/oak-d-lite-module/vision_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ class VisionWebServer:
### API
- GET:
- /: get the API information (any method)
- /latest_inference: get the latest inference result (404 if no inference result is
available - no pipeline running)
- /models_info: get a json-formatted string containing the information of the available
models
- /latest_inference: get the latest inference result (404 if no inference
result is available - no pipeline running)
- /models_info: get a json-formatted string containing the information of the
available models
- /model: get the name of the currently active model (empty string if none)
- POST:
- /: get the API information (for POST only)
- /change_model?model=<model name>: switch the currently active model for the one
specified in the parameter; Error 422 if model name is invalid
- /change_model?model=<model name>: switch the currently active model for the
one specified in the parameter; Error 422 if model name is invalid
"""

exposed = True
Expand Down Expand Up @@ -95,7 +95,7 @@ def __init__(self, config_path: str, models_path: str, public: bool = True):
self.msg_ok = {"status": "SUCCESS", "msg": "", "params": {}}
self.msg_ko = {"status": "FAILURE", "msg": "", "params": {}}

def GET(self, *path, **params):
def GET(self, *path):
"""
GET
---
Expand All @@ -114,18 +114,17 @@ def GET(self, *path, **params):
# No model is currently active
raise cp.HTTPError(
404,
"No inference result found - need to launch a pipeline first (POST)",
"No inference result found - need to launch a pipeline first",
)
else:
cp.response.status = 200
return json.dumps(self.oak_control.last_inference_result)
cp.response.status = 200
return json.dumps(self.oak_control.last_inference_result)
elif str(path[0]) == "models_info":
return json.dumps(self.oak_control.info_dict)
elif str(path[0]) == "model":
# Return currently active model (Empty string if no active model!)
return self.oak_control.getCurrentModelName()
else:
cp.response.status = 418
cp.response.status = 200
return f"Available methods:\n{json.dumps(self.supported_req)}"

def POST(self, *path, **params):
Expand All @@ -136,8 +135,8 @@ def POST(self, *path, **params):
### Possible URLs
- /: get the API information (for POST only)
- /change_model?model=<model name>: switch the currently active model for the one
specified in the parameter; Error 422 if model name is invalid
- /change_model?model=<model name>: switch the currently active model for the
one specified in the parameter; Error 422 if model name is invalid
"""
# body = json.loads(cp.request.body.read())
if len(path) > 0 and len(params) > 0:
Expand All @@ -146,7 +145,8 @@ def POST(self, *path, **params):
if new_model not in self.oak_control.model_names:
raise cp.HTTPError(
422,
f"Parameter 'mode' = {new_model} is invalid!\nValid models: {self.oak_control.model_names}",
f"""Parameter 'mode' = {new_model} is invalid!\nValid models:
{self.oak_control.model_names}""",
)
# If valid model name, switch to that
self.oak_control.selectModel(new_model)
Expand All @@ -157,10 +157,9 @@ def POST(self, *path, **params):
return json.dumps(
self.oak_control.info_dict[self.oak_control.getCurrentModelName()]
)
else:
raise cp.HTTPError(
404, f"Invalid POST request to {self.own_addr + str(path[0])}"
)
raise cp.HTTPError(
404, f"Invalid POST request to {self.own_addr + str(path[0])}"
)
else:
return json.dumps(self.supported_req["POST"])

Expand Down

0 comments on commit 4e8c741

Please sign in to comment.