-
Notifications
You must be signed in to change notification settings - Fork 1
feat: handle requested environment variables #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
b717033 to
0cd274c
Compare
0cd274c to
5e1681c
Compare
Ja, aber ist schon angenehmer, wenn solche Standard-Sachen direkt definiert sind. Wenn wir die CPU-Nutzung per cgroups einschränken, sollten wir am besten den Wert auch dynamisch setzen. |
648a3ee to
01c677e
Compare
01c677e to
4efec60
Compare
| ) | ||
|
|
||
| ENVIRONMENT_VARIABLE_REGEX: Final[str] = r"[a-zA-Z_][a-zA-Z0-9_]*" | ||
| ENVIRONMENT_VARIABLE = Annotated[str, Field(pattern=f"^{ENVIRONMENT_VARIABLE_REGEX}$")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicht eher EnvironmentVariable bzw. EnvironmentVariableName?
| class Selector[T: Selectable, V](ABC): | ||
| """Provides helpful methods for getting package and request specific data.""" | ||
|
|
||
| def __init__(self, selectables: list[T]): | ||
| self._cache: LRUCacheMemory[SelectorQuery, V] = LRUCacheMemory(max_size=128) | ||
| self._selectables = selectables | ||
|
|
||
| def _get_matching(self, query: SelectorQuery) -> T | None: | ||
| """Gets the first matching selectable, if any. | ||
| It assumes that the selectables are ordered from least specific to most specific. | ||
| """ | ||
| for selectable in reversed(self._selectables): | ||
| if _is_matching(selectable.package_selector, query): | ||
| return selectable | ||
| return None | ||
|
|
||
| def get(self, query: SelectorQuery) -> V: | ||
| """Gets the result of the query, which may be cached.""" | ||
| if cached := self._cache.get(query): | ||
| return cached | ||
|
|
||
| result = self._get(query) | ||
| self._cache.put(query, result) | ||
|
|
||
| return result | ||
|
|
||
| @abstractmethod | ||
| def _get(self, query: SelectorQuery) -> V: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ich denke diese Klasse vermischt ein paar Dinge:
getcached_get_matchingmacht in 4 Zeilen das, was eigentlich im Klassennamen steht, und wählt den richtigen Eintrag aus den Selectables aus._getmachen in den Impls ziemlich verschiedene Dinge
Ich würde vorschlagen, das etwas zu refactoren:
_get_matchingwird eine Funktion (oderSelectoreine nicht-abstrakte Klasse, die nur das macht)PackagePermissionsHandlerundEnvironmentVariablesHandlerhaben keine Superklasse, sondern verwenden die neue Funktion- Die
_getwerden in den jeweiligen Klassen public. Falls Caching doch nötig sein sollte, sollte das da passieren.
Closes #191
Mit
VAR: ${QPY_VAR}wird der Wert der UmgebungsvariableQPY_VARgelesen und verwendet. Wenn man explizit${QPY_VAR}als Wert übergeben will, müssen zwei Dollarzeichen verwendet werden:$${QPY_VAR}. Dieses Verhalten ähnelt dem von Docker und systemd.Wollen wir weiterhin
OPENBLAS_NUM_THREADSdemSubprocessWorkerübergeben? Theoretisch kann ein Admin das jetzt selber einstellen.