Skip to main content

sciencehub

Use the functions and data of ScienceHub projects from Python.

A ScienceHub project is a marimo notebook. Every function its author wrote as a reusable function (@app.function) can be called from your own code, and every file kept beside the notebook can be downloaded. Each project page lists them under Functions and Files.

pip install sciencehub

Load a project

import sciencehub as sh

ocean = sh.load("ada/ocean-heat")
ocean
ada/ocean-heat · Ocean heat content
version 7Q2M4XKD, the current one · https://sciencehub.sh/ada/ocean-heat

Functions
  heat_content(depth_m: float = 700) -> float
      Heat content above a depth, in joules per square metre.
Files
  data/argo.csv  14.2 kB

Pin this version: sh.load("ada/ocean-heat", version="01K7…7Q2M4XKD")

sh.load takes the name from the project's address: "owner/project" for its main notebook, "owner/project/notebook" for another one, or the address itself.

Call a function

help(ocean.heat_content)
ocean.heat_content(depth_m=700)

help(), inspect.signature, Jupyter's ? and editor completion show the signature and docstring the author wrote, before anything is downloaded.

The first call downloads the notebook and its files into a cache, imports the notebook, and calls the function on your computer. The function runs with the notebook's folder as its working directory, so a function that opens data/argo.csv finds it, as it does on ScienceHub.

The notebook's own dependencies have to be installed in your Python. If one is missing, the error names it; ocean.install() installs everything the notebook declares, with pip or uv.

Calling a function runs its author's code, as installing their package would.

Read a file

path = ocean.path("data/argo.csv")   # downloaded once, checked, then read from disk
with ocean.open("data/argo.csv") as handle:
    ...
ocean.download()                     # the notebook and every file, in one folder

Files of public projects also have an address any program can read:

import pandas as pd

df = pd.read_csv("https://sciencehub.sh/ada/ocean-heat/raw/data/argo.csv")

Pin a version

A load is always one version, and ocean.version says which. Pin it so your results do not change when the author saves a new one:

sh.load("ada/ocean-heat", version="01K7…")   # one saved version
sh.load("ada/ocean-heat", release=2)         # what DOI release 2 names, files included

Private projects

Make a personal access token with the read scope at sciencehub.sh/settings/tokens and set it as SCIENCEHUB_TOKEN, or pass token= to sh.load.

Settings

Variable What it does
SCIENCEHUB_TOKEN A personal access token, for private projects
SCIENCEHUB_URL Another ScienceHub site than https://sciencehub.sh
SCIENCEHUB_CACHE Where versions are kept; the user cache by default

Apache 2.0.

Metadata

Release files for sciencehub 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sciencehub 0.1.0
File Size Uploaded
sciencehub-0.1.0.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sciencehub 0.1.0
File Interpreter ABI Platform
sciencehub-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.5 kB

Release files / sciencehub-0.1.0.tar.gz

Download URL sciencehub-0.1.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
659a6688be064a80edeaf856d5ca07b6af719df615ba7ab0f14b9fb9bfb61063
BLAKE2b-256 checksum
How to use checksums
fe4ab9ac386633540f1f74542ed6d2abc9ad181b87f8054bbde37b158869d471
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sciencehub-0.1.0-py3-none-any.whl

Download URL sciencehub-0.1.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9862c718a86977df84f14a4754d044fe202a93542579d38604ff8a25ce5b823c
BLAKE2b-256 checksum
How to use checksums
5aa992009a5f76bc72cc8b1ebca55ae6affa58664cc7d1f838522d0146de09fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page