Skip to content
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

Add custom snippet path support #3388

Open
coderberry opened this issue Jan 9, 2025 · 1 comment
Open

Add custom snippet path support #3388

coderberry opened this issue Jan 9, 2025 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@coderberry
Copy link

Description

I would like to be able to have Marimo include a custom path to snippets that will load within the snippets list.

Suggested solution

I imagine this would be provided in two ways:

  1. Via the pyproject.toml file:
[project]
name = "marimo-example"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = []
custom_snippet_path = "./_snippets"
  1. Via an ENV variable:
CUSTOM_SNIPPET_PATH=./_snippets marimo edit

This path would then be added to the snippet_files method in marimo/_snippets/snippets.py file:

def snippet_files() -> Generator[str, Any, None]:
    root = os.path.realpath(
        str(import_files("marimo").joinpath("_snippets").joinpath("data"))
    )
    for _root, _dirs, files in os.walk(root):
        for file in files:
            if file.endswith(".py"):
                yield os.path.join(root, file)

Alternative

I have considered using metaprogramming to override this method, but a core solution would be much better.

Additional context

This will allow for massive adoption within my dev team and would allow us to share knowledge and snippets across different notebooks that are all within the same marimo edit server

@coderberry coderberry added the enhancement New feature or request label Jan 9, 2025
@mscolnick
Copy link
Contributor

Looks great! we can definitely start with option 1) as the config. and we can put it under [tool.marimo] like we do for our other configuration.

@mscolnick mscolnick added good first issue Good for newcomers help wanted Extra attention is needed labels Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants