-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor public Treescope API and set up packaging.
- Moves top-level API functions to be defined in treescope._internal.api and re-exported in treescope, instead of being in two places. - Renames `treescope.renderer` to `treescope.renderers`. - Sets up Python packaging and test runners. - Renames custom autovisualization tag type. - Removes support for labels above or below integer digitboxes, which do not render correctly. - Simplifies global configuration by removing "interactive context" stack. PiperOrigin-RevId: 653641608 Change-Id: I1668950281954ce85e262a867a9ecb1f9b573459
- Loading branch information
1 parent
adf28ff
commit 13eede1
Showing
32 changed files
with
433 additions
and
319 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,32 @@ | ||
name: Unittests | ||
|
||
# Allow to trigger the workflow manually (e.g. when deps changes) | ||
on: [push, workflow_dispatch] | ||
|
||
jobs: | ||
unittest-job: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# Install deps | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.10.14 | ||
# Uncomment to cache of pip dependencies (if tests too slow) | ||
# cache: pip | ||
# cache-dependency-path: '**/pyproject.toml' | ||
|
||
- run: pip --version | ||
- run: pip install -e .[dev,extras] | ||
- run: pip freeze | ||
|
||
# Run tests | ||
- name: Run tests | ||
run: python run_tests.py |
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,77 @@ | ||
[project] | ||
# Project metadata. Available keys are documented at: | ||
# https://packaging.python.org/en/latest/specifications/declaring-project-metadata | ||
name = "treescope" | ||
description = "Treescope: An interactive HTML pretty-printer for ML research in IPython notebooks." | ||
readme = "README.md" | ||
requires-python = ">=3.10" | ||
license = {file = "LICENSE"} | ||
authors = [{name = "The Treescope Authors", email="[email protected]"}] | ||
classifiers = [ | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Intended Audience :: Science/Research", | ||
] | ||
keywords = [] | ||
|
||
# Pip dependencies of the project. | ||
dependencies = [ | ||
"numpy>=1.25.2" | ||
] | ||
|
||
# This is set automatically by flit using `treescope.__version__` | ||
dynamic = ["version"] | ||
|
||
[project.urls] | ||
homepage = "https://github.com/google-deepmind/treescope" | ||
repository = "https://github.com/google-deepmind/treescope" | ||
|
||
[project.optional-dependencies] | ||
# Dependencies required for running tests. | ||
test = [ | ||
"absl-py>=1.4.0", | ||
"jax>=0.4.23", | ||
"pytest>=8.2.2", | ||
"torch>=2.0.0", | ||
] | ||
# Extra dependencies for some notebook demos. | ||
notebook = [ | ||
"ipython", | ||
"palettable", | ||
"jax>=0.4.23", | ||
] | ||
# Development deps (linting, formating,...) | ||
# Installed through `pip install .[dev]` | ||
dev = [ | ||
"pylint>=2.6.0", | ||
"pyink>=24.3.0", | ||
"ipython", | ||
"jupyter", | ||
] | ||
# Requirements for building documentation. | ||
docs = [ | ||
"ipython", | ||
"sphinx>=6.0.0,<7.3.0", | ||
"sphinx-book-theme>=1.0.1", | ||
"sphinxcontrib-katex", | ||
"ipython>=8.8.0", | ||
"myst-nb>=1.0.0", | ||
"myst-parser>=3.0.1", | ||
"matplotlib>=3.5.0", | ||
"sphinx-collections>=0.0.1", | ||
"sphinx_contributors", | ||
"sphinx-hoverxref", | ||
"jax[cpu]>=0.4.23", | ||
] | ||
|
||
[tool.pyink] | ||
# Formatting configuration to follow Google style-guide | ||
line-length = 80 | ||
unstable = true | ||
pyink-indentation = 2 | ||
pyink-use-majority-quotes = true | ||
|
||
[build-system] | ||
requires = ["flit_core >=3.8,<4"] | ||
build-backend = "flit_core.buildapi" |
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,19 @@ | ||
# Copyright 2024 The Treescope Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Entry point executable to run all tests.""" | ||
|
||
import subprocess | ||
|
||
if __name__ == "__main__": | ||
subprocess.check_call(["python", "-m", "pytest"]) |
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
Oops, something went wrong.