-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added infrastructure to run local Jupyter Lab instance and also added…
… pre-commit configuration
- Loading branch information
Showing
8 changed files
with
208 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" # See documentation for possible values | ||
directory: ".github/workflows" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
groups: | ||
actions: | ||
patterns: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ __pycache__ | |
dist | ||
build | ||
.ipynb_checkpoints | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
ci: | ||
autofix_prs: false | ||
autoupdate_schedule: 'monthly' | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: check-added-large-files | ||
args: ["--enforce-all", "--maxkb=300"] | ||
- id: check-case-conflict | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: check-toml | ||
- id: check-xml | ||
- id: check-yaml | ||
exclude: ".*(.github.*)$" | ||
- id: detect-private-key | ||
- id: end-of-file-fixer | ||
exclude: ".*(data.*|extern.*|licenses.*|_static.*|_parsetab.py)$" | ||
- id: trailing-whitespace | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: "v0.3.4" | ||
hooks: | ||
- id: ruff | ||
args: ["--fix", "--show-fixes"] | ||
- id: ruff-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
from ._monitor import monitor | ||
from ._version import __version__ | ||
|
||
__all__ = ["monitor", "__version__"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from contextlib import contextmanager | ||
|
||
from solara.test.pytest_plugin import ( | ||
ServerJupyter, | ||
) | ||
|
||
from ._utils import get_free_port | ||
|
||
__all__ = ["jupyter_server"] | ||
|
||
|
||
@contextmanager | ||
def jupyter_server(notebook_path): | ||
server = ServerJupyter(notebook_path, get_free_port(), "localhost") | ||
try: | ||
server.serve_threaded() | ||
server.wait_until_serving() | ||
yield server | ||
finally: | ||
server.stop_serving() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import datetime | ||
import socket | ||
|
||
from nbconvert import NotebookExporter | ||
from traitlets.config import Config | ||
|
||
__all__ = ["get_free_port", "clear_notebook", "isotime"] | ||
|
||
|
||
def get_free_port(): | ||
"""Return a free port number.""" | ||
sock = socket.socket() | ||
sock.bind(("", 0)) | ||
return sock.getsockname()[1] | ||
|
||
|
||
def clear_notebook(input_notebook, output_notebook): | ||
"""Write out a copy of the notebook with output and metadata removed.""" | ||
c = Config() | ||
c.NotebookExporter.preprocessors = [ | ||
"nbconvert.preprocessors.ClearOutputPreprocessor", | ||
"nbconvert.preprocessors.ClearMetadataPreprocessor", | ||
] | ||
|
||
exporter = NotebookExporter(config=c) | ||
body, resources = exporter.from_filename(input_notebook) | ||
|
||
with open(output_notebook, "w") as f: | ||
f.write(body) | ||
|
||
|
||
def isotime(): | ||
return datetime.datetime.now().isoformat() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters