-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up the exporter and use uvicorn instead
- Loading branch information
Showing
18 changed files
with
1,847 additions
and
609 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,32 @@ | ||
[flake8] | ||
# it's not a bug that we aren't using all of hacking, | ||
# ignore H101,H238,H301,H306 | ||
ignore = E226,E302,E41,H101,H238,H301,H306 | ||
max-line-length = 120 | ||
exclude = | ||
.git, | ||
__pycache__, | ||
old, | ||
build, | ||
dist, | ||
migrations, | ||
*.pyc, | ||
*.pyo, | ||
*.pyd, | ||
*.egg, | ||
*.egg-info, | ||
.cache, | ||
.eggs, | ||
.tox, | ||
.venv, | ||
_build, | ||
buck-out, | ||
venv, | ||
*.mo, | ||
*.so, | ||
*.com, | ||
*.class, | ||
*.dll, | ||
*.exe | ||
max-complexity = 10 | ||
select = B,C,E,F,W,T4,B9 |
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,20 +1,20 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.9-slim | ||
# Use the official Python image from the Docker Hub | ||
FROM python:3.11-slim | ||
|
||
# Set the working directory in the container to /app | ||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Add the current directory contents into the container at /app | ||
ADD . /app | ||
# Copy the distribution file into the container | ||
COPY dist/*.whl /app/ | ||
|
||
# Install any needed packages specified in requirements.txt | ||
RUN pip install -q --no-cache-dir -r requirements.txt | ||
# Install the distribution file using pip | ||
RUN pip install --no-cache-dir /app/*.whl | ||
|
||
# Make port 80 available to the world outside this container | ||
EXPOSE 9992 | ||
# Copy the rest of the application code into the container | ||
COPY . . | ||
|
||
# Define environment variable | ||
ENV NAME FastAPIApp | ||
# Expose port 9992 to the outside world | ||
EXPOSE 9992 | ||
|
||
# Run main.py when the container launches | ||
CMD ["hypercorn", "asgi:app", "--bind", "0.0.0.0:9992"] | ||
# Command to run the FastAPI application using Uvicorn | ||
CMD ["uvicorn", "asgi:app", "--host", "0.0.0.0", "--port", "9992"] |
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,5 @@ | ||
""" ASGI entrypoint for Lutron QS Exporter.""" | ||
from lutron_qs_exporter import app | ||
|
||
__all__ = ["app"] | ||
|
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 |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
"port": 23, | ||
"username": "default", | ||
"password": "default", | ||
"log_level": "INFO" | ||
"log_level": "DEBUG" | ||
} |
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 +1,2 @@ | ||
hypercorn asgi:app --reload | ||
$env:LOG_LEVEL = "WARN" | ||
uvicorn --reload asgi:app |
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,10 +1,19 @@ | ||
# Define image and container name | ||
$ImageName = "lutron_qs_exporter" | ||
|
||
# Delete 'dist' folder if it exists | ||
if (Test-Path -Path .\dist -PathType Container) { | ||
Remove-Item -Path .\dist -Recurse -Force | ||
} | ||
|
||
# Run poetry build | ||
Write-Output "Running poetry build..." | ||
poetry build | ||
Write-Output "Poetry build completed." | ||
|
||
Write-Output "Building Docker image: $ImageName" | ||
|
||
# Build the Docker image | ||
docker build -t $ImageName . | ||
|
||
Write-Output "Image $ImageName built successfully." | ||
|
||
Write-Output "Image $ImageName built successfully." |
Oops, something went wrong.