mirror of
https://gitea.publichub.eu/oscar.krause/fastapi-dls.git
synced 2026-04-08 22:15:47 +03:00
Compare commits
13 Commits
3fe3429986
...
1.5.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b54d4794b | ||
|
|
9605ba3eee | ||
|
|
cd5c2a6cb1 | ||
|
|
1d3255188e | ||
|
|
cea7a01b54 | ||
|
|
9f417b61a9 | ||
|
|
4f77200628 | ||
|
|
20b03446dc | ||
|
|
df506e8591 | ||
|
|
e2c4e45764 | ||
|
|
9e5b4f5a42 | ||
|
|
f9c7475250 | ||
|
|
00dafdc63a |
@@ -16,12 +16,12 @@ build:docker:
|
|||||||
interruptible: true
|
interruptible: true
|
||||||
stage: build
|
stage: build
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
# deployment is in "deploy:docker:"
|
||||||
|
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
||||||
changes:
|
changes:
|
||||||
- app/**/*
|
- app/**/*
|
||||||
- Dockerfile
|
- Dockerfile
|
||||||
- requirements.txt
|
- requirements.txt
|
||||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
|
||||||
tags: [ docker ]
|
tags: [ docker ]
|
||||||
before_script:
|
before_script:
|
||||||
- docker buildx inspect
|
- docker buildx inspect
|
||||||
@@ -44,16 +44,13 @@ build:apt:
|
|||||||
- if: $CI_COMMIT_TAG
|
- if: $CI_COMMIT_TAG
|
||||||
variables:
|
variables:
|
||||||
VERSION: $CI_COMMIT_REF_NAME
|
VERSION: $CI_COMMIT_REF_NAME
|
||||||
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
- if: ($CI_PIPELINE_SOURCE == 'merge_request_event') || ($CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH)
|
||||||
changes:
|
changes:
|
||||||
- app/**/*
|
- app/**/*
|
||||||
- .DEBIAN/**/*
|
- .DEBIAN/**/*
|
||||||
- .gitlab-ci.yml
|
- .gitlab-ci.yml
|
||||||
variables:
|
variables:
|
||||||
VERSION: "0.0.1"
|
VERSION: "0.0.1"
|
||||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
|
||||||
variables:
|
|
||||||
VERSION: "0.0.1"
|
|
||||||
before_script:
|
before_script:
|
||||||
- echo -e "VERSION=$VERSION\nCOMMIT=$CI_COMMIT_SHA" > version.env
|
- echo -e "VERSION=$VERSION\nCOMMIT=$CI_COMMIT_SHA" > version.env
|
||||||
# install build dependencies
|
# install build dependencies
|
||||||
@@ -94,16 +91,13 @@ build:pacman:
|
|||||||
- if: $CI_COMMIT_TAG
|
- if: $CI_COMMIT_TAG
|
||||||
variables:
|
variables:
|
||||||
VERSION: $CI_COMMIT_REF_NAME
|
VERSION: $CI_COMMIT_REF_NAME
|
||||||
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
- if: ($CI_PIPELINE_SOURCE == 'merge_request_event') || ($CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH)
|
||||||
changes:
|
changes:
|
||||||
- app/**/*
|
- app/**/*
|
||||||
- .PKGBUILD/**/*
|
- .PKGBUILD/**/*
|
||||||
- .gitlab-ci.yml
|
- .gitlab-ci.yml
|
||||||
variables:
|
variables:
|
||||||
VERSION: "0.0.1"
|
VERSION: "0.0.1"
|
||||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
|
||||||
variables:
|
|
||||||
VERSION: "0.0.1"
|
|
||||||
before_script:
|
before_script:
|
||||||
#- echo -e "VERSION=$VERSION\nCOMMIT=$CI_COMMIT_SHA" > version.env
|
#- echo -e "VERSION=$VERSION\nCOMMIT=$CI_COMMIT_SHA" > version.env
|
||||||
# install build dependencies
|
# install build dependencies
|
||||||
@@ -143,12 +137,12 @@ test:python:
|
|||||||
matrix:
|
matrix:
|
||||||
- IMAGE:
|
- IMAGE:
|
||||||
# https://devguide.python.org/versions/#supported-versions
|
# https://devguide.python.org/versions/#supported-versions
|
||||||
- python:3.14-alpine # EOL 2030-10
|
# - python:3.14-rc-alpine # EOL 2030-10 => uvicorn does not support 3.14 yet
|
||||||
- python:3.13-alpine # EOL 2029-10
|
- python:3.13-alpine # EOL 2029-10
|
||||||
- python:3.12-alpine # EOL 2028-10
|
- python:3.12-alpine # EOL 2028-10
|
||||||
- python:3.11-alpine # EOL 2027-10
|
- python:3.11-alpine # EOL 2027-10
|
||||||
- python:3.10-alpine # EOL 2026-10
|
# - python:3.10-alpine # EOL 2026-10 => ImportError: cannot import name 'UTC' from 'datetime'
|
||||||
- python:3.9-alpine # EOL 2025-10
|
# - python:3.9-alpine # EOL 2025-10 => ImportError: cannot import name 'UTC' from 'datetime'
|
||||||
before_script:
|
before_script:
|
||||||
- apk --no-cache add openssl
|
- apk --no-cache add openssl
|
||||||
- python3 -m venv venv
|
- python3 -m venv venv
|
||||||
@@ -170,7 +164,8 @@ test:apt:
|
|||||||
image: $IMAGE
|
image: $IMAGE
|
||||||
stage: test
|
stage: test
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
|
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
||||||
changes:
|
changes:
|
||||||
- app/**/*
|
- app/**/*
|
||||||
- .DEBIAN/**/*
|
- .DEBIAN/**/*
|
||||||
@@ -217,11 +212,12 @@ test:apt:
|
|||||||
test:pacman:archlinux:
|
test:pacman:archlinux:
|
||||||
image: archlinux:base
|
image: archlinux:base
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
|
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
||||||
changes:
|
changes:
|
||||||
- app/**/*
|
- app/**/*
|
||||||
- .PKGBUILD/**/*
|
- .PKGBUILD/**/*
|
||||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
- .gitlab-ci.yml
|
||||||
needs:
|
needs:
|
||||||
- job: build:pacman
|
- job: build:pacman
|
||||||
artifacts: true
|
artifacts: true
|
||||||
@@ -384,7 +380,7 @@ deploy:pacman:
|
|||||||
release:
|
release:
|
||||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||||
stage: .post
|
stage: .post
|
||||||
needs: [ build:docker, build:apt, build:pacman ]
|
needs: [ deploy:docker, deploy:apt, deploy:pacman ]
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_TAG
|
- if: $CI_COMMIT_TAG
|
||||||
script:
|
script:
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -795,13 +795,13 @@ Thanks to vGPU community and all who uses this project and report bugs.
|
|||||||
|
|
||||||
Special thanks to:
|
Special thanks to:
|
||||||
|
|
||||||
- @samicrusader who created build file for **ArchLinux**
|
- `samicrusader` who created build file for **ArchLinux**
|
||||||
- @cyrus who wrote the section for **openSUSE**
|
- `cyrus` who wrote the section for **openSUSE**
|
||||||
- @midi who wrote the section for **unRAID**
|
- `midi` who wrote the section for **unRAID**
|
||||||
- @polloloco who wrote the *[NVIDIA vGPU Guide](https://gitlab.com/polloloco/vgpu-proxmox)*
|
- `polloloco` who wrote the *[NVIDIA vGPU Guide](https://gitlab.com/polloloco/vgpu-proxmox)*
|
||||||
- @DualCoder who creates the `vgpu_unlock` functionality [vgpu_unlock](https://github.com/DualCoder/vgpu_unlock)
|
- `DualCoder` who creates the `vgpu_unlock` functionality [vgpu_unlock](https://github.com/DualCoder/vgpu_unlock)
|
||||||
- Krutav Shah who wrote the [vGPU_Unlock Wiki](https://docs.google.com/document/d/1pzrWJ9h-zANCtyqRgS7Vzla0Y8Ea2-5z2HEi4X75d2Q/)
|
- `Krutav Shah` who wrote the [vGPU_Unlock Wiki](https://docs.google.com/document/d/1pzrWJ9h-zANCtyqRgS7Vzla0Y8Ea2-5z2HEi4X75d2Q/)
|
||||||
- Wim van 't Hoog for the [Proxmox All-In-One Installer Script](https://wvthoog.nl/proxmox-vgpu-v3/)
|
- `Wim van 't Hoog` for the [Proxmox All-In-One Installer Script](https://wvthoog.nl/proxmox-vgpu-v3/)
|
||||||
- @mrzenc who wrote [fastapi-dls-nixos](https://github.com/mrzenc/fastapi-dls-nixos)
|
- `mrzenc` who wrote [fastapi-dls-nixos](https://github.com/mrzenc/fastapi-dls-nixos)
|
||||||
|
|
||||||
And thanks to all people who contributed to all these libraries!
|
And thanks to all people who contributed to all these libraries!
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from sqlalchemy import Column, VARCHAR, CHAR, ForeignKey, DATETIME, update, and_
|
|||||||
from sqlalchemy.engine import Engine
|
from sqlalchemy.engine import Engine
|
||||||
from sqlalchemy.orm import sessionmaker, declarative_base
|
from sqlalchemy.orm import sessionmaker, declarative_base
|
||||||
|
|
||||||
from util import NV
|
from util import DriverMatrix
|
||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ class Origin(Base):
|
|||||||
return f'Origin(origin_ref={self.origin_ref}, hostname={self.hostname})'
|
return f'Origin(origin_ref={self.origin_ref}, hostname={self.hostname})'
|
||||||
|
|
||||||
def serialize(self) -> dict:
|
def serialize(self) -> dict:
|
||||||
_ = NV().find(self.guest_driver_version)
|
_ = DriverMatrix().find(self.guest_driver_version)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'origin_ref': self.origin_ref,
|
'origin_ref': self.origin_ref,
|
||||||
|
|||||||
44
app/util.py
44
app/util.py
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from json import load as json_load
|
||||||
|
|
||||||
from cryptography.hazmat.primitives import serialization
|
from cryptography.hazmat.primitives import serialization
|
||||||
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey, generate_private_key
|
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey, generate_private_key
|
||||||
@@ -7,6 +8,14 @@ from cryptography.hazmat.primitives.serialization import load_pem_private_key, l
|
|||||||
logging.basicConfig()
|
logging.basicConfig()
|
||||||
|
|
||||||
|
|
||||||
|
def load_file(filename: str) -> bytes:
|
||||||
|
log = logging.getLogger(f'{__name__}')
|
||||||
|
log.debug(f'Loading contents of file "{filename}')
|
||||||
|
with open(filename, 'rb') as file:
|
||||||
|
content = file.read()
|
||||||
|
return content
|
||||||
|
|
||||||
|
|
||||||
class PrivateKey:
|
class PrivateKey:
|
||||||
|
|
||||||
def __init__(self, data: bytes):
|
def __init__(self, data: bytes):
|
||||||
@@ -76,37 +85,32 @@ class PublicKey:
|
|||||||
format=serialization.PublicFormat.SubjectPublicKeyInfo
|
format=serialization.PublicFormat.SubjectPublicKeyInfo
|
||||||
)
|
)
|
||||||
|
|
||||||
def load_file(filename: str) -> bytes:
|
|
||||||
log = logging.getLogger(f'{__name__}')
|
|
||||||
log.debug(f'Loading contents of file "{filename}')
|
|
||||||
with open(filename, 'rb') as file:
|
|
||||||
content = file.read()
|
|
||||||
return content
|
|
||||||
|
|
||||||
|
class DriverMatrix:
|
||||||
class NV:
|
|
||||||
__DRIVER_MATRIX_FILENAME = 'static/driver_matrix.json'
|
__DRIVER_MATRIX_FILENAME = 'static/driver_matrix.json'
|
||||||
__DRIVER_MATRIX: None | dict = None # https://docs.nvidia.com/grid/ => "Driver Versions"
|
__DRIVER_MATRIX: None | dict = None # https://docs.nvidia.com/grid/ => "Driver Versions"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.log = logging.getLogger(self.__class__.__name__)
|
self.log = logging.getLogger(self.__class__.__name__)
|
||||||
|
|
||||||
if NV.__DRIVER_MATRIX is None:
|
if DriverMatrix.__DRIVER_MATRIX is None:
|
||||||
from json import load as json_load
|
self.__load()
|
||||||
try:
|
|
||||||
file = open(NV.__DRIVER_MATRIX_FILENAME)
|
def __load(self):
|
||||||
NV.__DRIVER_MATRIX = json_load(file)
|
try:
|
||||||
file.close()
|
file = open(DriverMatrix.__DRIVER_MATRIX_FILENAME)
|
||||||
self.log.debug(f'Successfully loaded "{NV.__DRIVER_MATRIX_FILENAME}".')
|
DriverMatrix.__DRIVER_MATRIX = json_load(file)
|
||||||
except Exception as e:
|
file.close()
|
||||||
NV.__DRIVER_MATRIX = {} # init empty dict to not try open file everytime, just when restarting app
|
self.log.debug(f'Successfully loaded "{DriverMatrix.__DRIVER_MATRIX_FILENAME}".')
|
||||||
# self.log.warning(f'Failed to load "{NV.__DRIVER_MATRIX_FILENAME}": {e}')
|
except Exception as e:
|
||||||
|
DriverMatrix.__DRIVER_MATRIX = {} # init empty dict to not try open file everytime, just when restarting app
|
||||||
|
# self.log.warning(f'Failed to load "{NV.__DRIVER_MATRIX_FILENAME}": {e}')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def find(version: str) -> dict | None:
|
def find(version: str) -> dict | None:
|
||||||
if NV.__DRIVER_MATRIX is None:
|
if DriverMatrix.__DRIVER_MATRIX is None:
|
||||||
return None
|
return None
|
||||||
for idx, (key, branch) in enumerate(NV.__DRIVER_MATRIX.items()):
|
for idx, (key, branch) in enumerate(DriverMatrix.__DRIVER_MATRIX.items()):
|
||||||
for release in branch.get('$releases'):
|
for release in branch.get('$releases'):
|
||||||
linux_driver = release.get('Linux Driver')
|
linux_driver = release.get('Linux Driver')
|
||||||
windows_driver = release.get('Windows Driver')
|
windows_driver = release.get('Windows Driver')
|
||||||
|
|||||||
Reference in New Issue
Block a user