Tensorbored torch import issue#63
Merged
Merged
Conversation
torch.py was missing from the built wheel because: 1. It had no Bazel py_library target in tensorbored/BUILD, so the Bazel-based build_pip_package never copied it into the wheel. 2. pyproject.toml lacked a [tool.setuptools.packages.find] directive, causing setuptools flat-layout auto-discovery to fail when building directly from the repo root. Add the 'torch' Bazel target, wire it into pip_package/BUILD data deps, and pin setuptools package discovery to 'tensorbored*'. Co-authored-by: Samuel <samuel@knutsen.co>
The demo is supposed to represent basic library usage, but was using
low-level internals (event_pb2, summary_pb2, TensorProto,
EventFileWriter) to construct and write summaries by hand.
Replace all of that with the recommended user-facing API:
from tensorbored.torch import SummaryWriter
writer = SummaryWriter(log_dir=...)
writer.add_scalar(...)
writer.add_histogram(...)
writer.add_image(..., dataformats='HWC')
writer.add_text(...)
This removes ~80 lines of boilerplate (make_scalar_summary,
make_image_summary, make_histogram_summary, make_text_summary,
add_summary) and makes the demo match the README's recommended usage.
Co-authored-by: Samuel <samuel@knutsen.co>
|
Cursor Agent can help with this pull request. Just |
Preview Deployment
Details
|
Without __main__.py in the wheel, running 'python -m tensorbored'
fails with:
No module named tensorbored.__main__; 'tensorbored' is a package
and cannot be directly executed
Add a Bazel py_library target and wire it into the pip package build.
Co-authored-by: Samuel <samuel@knutsen.co>
Co-authored-by: Samuel <samuel@knutsen.co>
Co-authored-by: Samuel <samuel@knutsen.co>
The demo now uses 'from tensorbored.torch import SummaryWriter' which requires torch. Add the CPU-only wheel to keep the image small. Co-authored-by: Samuel <samuel@knutsen.co>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation for features / changes
This PR addresses two key issues:
tensorbored.torch.SummaryWriterwas not importable from the PyPI package. Thetorch.pyfile, which provides theSummaryWriterintegration, was missing from the published wheel, preventing users from following the README's suggested usage.demo/generate_demo_data.py) was overly complex and misleading. It used low-level protobuf APIs to write events, rather than showcasing the intended high-levelSummaryWriterAPI. This made the demo a poor example of basic library usage.Technical description of changes
torch.pyin the pip package:py_librarytarget fortorch.pyintensorbored/BUILD.build_pip_packagerule intensorbored/pip_package/BUILD.[tool.setuptools.packages.find]configuration topyproject.tomlto ensure correct package discovery during local builds.demo/generate_demo_data.py:from tensorbored.torch import SummaryWriterand itsadd_scalar,add_histogram,add_image, andadd_textmethods.Screenshots of UI changes (or N/A)
N/A
Detailed steps to verify changes work correctly (as executed by you)
pip install torch.python -m build.pip install dist/tensorbored-*-py3-none-any.whl).tensorbored.torch.SummaryWriteris importable:python -c "from tensorbored.torch import SummaryWriter; print(SummaryWriter)"python demo/generate_demo_data.py.runs/directory.Alternate designs / implementations considered (or N/A)
N/A