Skip to content

Commit a1ce923

Browse files
committed
feat: work with env vars
1 parent ab54902 commit a1ce923

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

frontend/src/types/Manifest.generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface Manifest {
3232
type: PackageType
3333
license: string | null
3434
permissions: PartialPackagePermissions | null
35+
environment_variables: string[] | null
3536
tags: string[]
3637
requirements: string | string[] | null
3738
static_files: StaticFiles

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies = [
1818
"aiohttp >=3.11.18, <4.0.0",
1919
"pydantic >=2.11.4, <3.0.0",
2020
"PyYAML >=6.0.2, <7.0.0",
21-
"questionpy-server @ git+https://github.com/questionpy-org/questionpy-server.git@a9f052d552e68268684792e028279feabae2c2e2",
21+
"questionpy-server @ git+https://github.com/questionpy-org/questionpy-server.git@5e1681cbc19ebdbfe04a4500024f1cd6d9128ca9",
2222
"jinja2 >=3.1.6, <4.0.0",
2323
"aiohttp-jinja2 >=1.6, <2.0",
2424
"lxml[html-clean] >=5.4.0, <5.5.0",

questionpy_sdk/webserver/controllers/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file is part of the QuestionPy SDK. (https://questionpy.org)
22
# The QuestionPy SDK is free software released under terms of the MIT license. See LICENSE.md.
33
# (c) Technische Universität Berlin, innoCampus <info@isis.tu-berlin.de>
4-
4+
import os
55
from collections.abc import AsyncIterator
66
from contextlib import asynccontextmanager
77
from typing import TYPE_CHECKING
@@ -26,7 +26,11 @@ def generate_api_url(self, name: str, **kwargs: str) -> URL:
2626
@asynccontextmanager
2727
async def get_worker(self) -> AsyncIterator[Worker]:
2828
async with self._webserver.worker_pool.get_worker(
29-
self._webserver.package_location, "sdk", "sdk", self._webserver.package_permissions
29+
self._webserver.package_location,
30+
"sdk",
31+
"sdk",
32+
self._webserver.package_permissions,
33+
os.environ.copy(),
3034
) as worker:
3135
yield worker
3236

questionpy_sdk/webserver/server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# (c) Technische Universität Berlin, innoCampus <info@isis.tu-berlin.de>
44

55
import logging
6+
import os
67
from pathlib import Path
78
from types import TracebackType
89
from typing import ClassVar, NotRequired, Self, TypedDict, Unpack
@@ -59,6 +60,12 @@ async def __aenter__(self) -> Self:
5960
# Read manifest
6061
self._manifest = await read_manifest(self.package_location)
6162

63+
# Check if required environment variables are set
64+
requested_environment_variables = self._manifest.environment_variables or set()
65+
if missing_environment_variables := requested_environment_variables - os.environ.keys():
66+
msg = f"Required environment variables not set: {missing_environment_variables}"
67+
raise ValueError(msg)
68+
6269
# Assemble worker permissions
6370
permissions = CompletePackagePermissions()
6471
if self._manifest.permissions:

0 commit comments

Comments
 (0)