Warning: This blog post references deprecated XetHub links and functionality. Please use as a reference only and follow our current work on Hugging Face.

July 18, 2024

Introducing Custom Views: From Binary Blobs to Shared Insights

Jared Sulzdorf

Jared Sulzdorf

Jared Sulzdorf

Have you ever tried to git diff two versions of a big file? Git’s representation of files is an incredibly powerful mechanism for tracking changes, particularly well-suited for relatively small files of code or text. However, as files grow in size and complexity, the changes in bits are less important than what those changes represent. As a result, reviewers of changes in large files frequently have to download the before and after of any file and load the contents into a different tool in order to identify differences.

Git diffs work well for code (left), but fail to provide meaningful diffs for larger or more complex file types (right).

XetHub custom views bridge the gap between raw files and human understandability, allowing data science and machine learning teams to choose how to display the information in their repository. Unlike static screenshots or manually generated changelogs that become outdated, our views are rendered live on repository files in XetHub for built-in context as you browse.

This feature is especially powerful when used to review changes, making it possible to grok binary file changes without needing to pull the files locally:

The NGL Viewer visualization shows up for supported file types, even in difference views.

Create your first custom view

It’s easy to create a view in XetHub: simply edit and run Python in the browser to save a view that will be persisted to your repository.

To get started, all you need is write access to a XetHub repository. From any page:

  1. Navigate to the file or directory where the view will appear and click the "Add a new custom view" button.

  2. Add your code to the Python editor that appears and click the “Run view" button (available in the upper right corner of the editor) to compile and execute your code. The final result will display in the output area.

  3. Once you're satisfied with the output, click the "Save view" button.

Your saved view will show whenever the associated file or directory is viewed in XetHub, and repository collaborators have the option to interact with Python editor and update views. Here’s a quick demo of the edit and save experience:

Our Python editor also doubles as a convenient means for collaborators to explore large data without leaving the browser.

How it works

Powered by JupyterLite and Pyodide, our Python editor allows you to import the a library to interact with repository files through helper functions like get_data_file(). The editor comes with pre-installed support for popular libraries like Pandas, Numpy, and Matplotlib. Install additional libraries as needed for your use case.

Behind the scenes, saving a view automatically creates a directory in the repository's .xethub/custom_views folder that contains a view.py with your Python code and view.yml with configuration details. On each save, your code is committed back to the repository for provenance.

Other views

  • Not a fan of Python? Need more interactivity? You can also create custom views using HTML, CSS, and JS, simply saving your code and configuration to your .xethub/custom_views/<view> directory to make the views show up.

  • XetHub provides built-in visualizations for file types supported by Netron, NGL Viewer, and 3dviewer. No changes are needed for these views to show up in your repository.

  • Views are inheritable! If you see a view that you like in another repo, just reference and tweak it for your own usage with a single line of code.

Conclusion

The lack of tooling for larger or more complex file types has had a price on developer experience, requiring context switching and manual examination for reviews. Our custom views aim to make this experience better by allowing users to bring the context to their repository files, establishing a shared understanding between collaborators.

We’re excited to share this feature with you and to hear your feedback.

Share on