Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ jobs:
buildfilename: './container/Containerfile'
version: ${{ needs.set-version.outputs.version }}

call-build-llamaserver:
name: "🤙 Call container workflow with `llamaserver`"
needs: ['set-version', 'check-deployment']
uses: ./.github/workflows/container.yml
secrets: inherit
with:
buildfilename: './container/llamaserver.containerfile'
version: ${{ needs.set-version.outputs.version }}

call-build-ffmpeg:
name: "🤙 Call container workflow with `ffmpeg`"
needs: ['set-version', 'call-build-base']
Expand Down
4 changes: 4 additions & 0 deletions build-tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def main():
"(useful if already installed)."
)
args = parser.parse_args()
# print each line at once: in CI stdout is a pipe, where python
# would hold these lines until exit, after the output of the
# commands they introduce
sys.stdout.reconfigure(line_buffering=True)

project_root = SCRIPT_DIR.parent

Expand Down
651 changes: 588 additions & 63 deletions clams/app/__init__.py

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions clams/appmetadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,29 @@ def __init__(self, **kwargs):
}


class EnvRequirement(_BaseModel):
"""
Defines a data model that describes an environment variable that a CLAMS
app cannot run without, such as an access token for a gated model. Only
the name of the variable is part of the app metadata, never its value.
"""
name: str = pydantic.Field(
...,
pattern=r'^[A-Za-z_][A-Za-z0-9_]*$',
description="Name of the environment variable."
)
description: str = pydantic.Field(
...,
description="Description of what the variable is for and how to "
"obtain its value."
)

model_config = {
'title': 'CLAMS App Environment Requirement',
'extra': 'forbid',
}


class AppMetadata(pydantic.BaseModel):
"""
Data model that describes a CLAMS app.
Expand Down Expand Up @@ -379,6 +402,14 @@ class AppMetadata(pydantic.BaseModel):
"The values declared here are propagated by the SDK into the ``appTags`` field of every view "
"the app signs."
)
env_requirements: List[EnvRequirement] = pydantic.Field(
[],
description="(optional) List of environment variables that the app "
"cannot run without. Being listed here means the variable "
"is required, so optional settings are left out. Values "
"of these variables are never part of app metadata or "
"output MMIF."
)
est_gpu_mem_min: int = pydantic.Field(
0,
description="(optional) Minimum GPU memory required to run the app, in megabytes (MB). "
Expand Down Expand Up @@ -567,6 +598,24 @@ def add_more(self, key: str, value: str):
raise ValueError(f"'{key}' is already being used in the appmetadata!")
else:
raise ValueError("Key and value should not be empty!")

def add_env_requirement(self, name: str,
description: str) -> EnvRequirement:
"""
Helper method to declare an environment variable that the app cannot
run without.

:param name: name of the environment variable
:param description: what the variable is for and how to get its value
:returns: the newly added
:class:`~clams.appmetadata.EnvRequirement` object
:raises ValueError: if the name is invalid or is already declared
"""
if any(env.name == name for env in self.env_requirements):
raise ValueError(f"'{name}' is already declared as required!")
new_env = EnvRequirement(name=name, description=description)
self.env_requirements.append(new_env)
return new_env

def jsonify(self, pretty=False):
"""
Expand Down
Loading
Loading