Skip to content

Commit

Permalink
enables environment variable configuration in frontmatter (#972)
Browse files Browse the repository at this point in the history
* enables environment variable configuration in frontmatter

* explicitly make env var dict items strings
  • Loading branch information
charlesfrye authored Nov 14, 2024
1 parent cd2d112 commit 2a142ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions 13_sandboxes/codelangchain/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# cmd: ["modal", "run", "13_sandboxes.codelangchain.agent", "--question", "Use gpt2 and transformers to generate text"]
# tags: ["featured", "use-case-sandboxed-code-execution"]
# pytest: false
# env: {"MODAL_AUTOMOUNT": "True"}
# ---

# # Build a coding agent with Modal Sandboxes and LangGraph
Expand Down
5 changes: 5 additions & 0 deletions internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class Example(BaseModel):
cli_args: Optional[list] = None # Full command line args to run it
stem: Optional[str] = None # stem of path
tags: Optional[list[str]] = None # metadata tags for the example
env: Optional[
dict[str, str]
] = None # environment variables for the example


_RE_NEWLINE = re.compile(r"\r?\n")
Expand Down Expand Up @@ -119,6 +122,7 @@ def gather_example_files(
cmd = metadata.get("cmd", ["modal", "run", repo_filename])
args = metadata.get("args", [])
tags = metadata.get("tags", [])
env = metadata.get("env", dict())
yield Example(
type=ExampleType.MODULE,
filename=filename_abs,
Expand All @@ -128,6 +132,7 @@ def gather_example_files(
cli_args=(cmd + args),
stem=Path(filename_abs).stem,
tags=tags,
env=env,
)
elif ext in [".png", ".jpeg", ".jpg", ".gif", ".mp4"]:
yield Example(
Expand Down

0 comments on commit 2a142ac

Please sign in to comment.