nanohub-results
Python library to interact with the NanoHUB Results API. This library provides a Pythonic interface for searching, filtering, and downloading simulation results from NanoHUB tools.
Features
- Pythonic Query Builder: Fluent interface with method chaining
- Field Validation: Automatic validation against tool schemas
- Operation Validation: Only valid operations (
=,!=,>,<,>=,<=,like,in) - Pagination: Automatic iteration over large result sets
- Complete API Coverage: Access to all dbexplorer and download endpoints
Installation
cd nanohub-results
pip install .
Quick Start
import nanohubremote as nr
from nanohubresults import Results
# Initialize session with authentication
auth_data = {
"grant_type": "personal_token",
"token": "your_token_here"
}
session = nr.Session(auth_data, url="https://nanohub.org/api")
results = Results(session)
# Get list of available tools
tools = results.get_tools(simtool=False)
print(tools)
# Search for results using the Query builder
response = results.query("2dfets") \
.filter("output.Id", ">", 1e-6) \
.select("output.Id", "output.Vt") \
.limit(10) \
.execute()
print(response)
Available Tools
Some example tools available on NanoHUB:
Rappture Tools:
2dfets- 2D FET I-V characteristics simulator1dphononbte- 1D Phonon BTE Solver for heat transportabinit- DFT calculations for molecules and periodic solids1dchainmd- 1D Chain Dispersions1dfdmht- 1D Finite Different Method Heat Transfer2dmatstacks- Electrostatic Properties of Layered 2D Materialsadept- Solar cell and semiconductor device modelingadvte- Advanced Thermoelectric Power Generation
Sim2L Tools:
alphafold231- AlphaFold 2.3.1 protein structure predictioncellrelaxdft- Cell Relax DFT calculationselasticdft- Elastic Constants with DFTgaussianthermo- First-Principles Thermochemical Dataset
Usage Examples
1. List Available Tools
# Get all simulation tools
tools = results.get_tools(simtool=True)
for tool in tools['results']:
print(f"{tool['tool_name']}: {tool['title']}")
2. Get Tool Schema
# Get detailed schema for a tool
schema = results.get_tool_detail("2dfets")
print(schema)
3. Search with Filters
# Search with multiple filters
query = results.query("1dphononbte") \
.filter("input.acoustic_length", ">", 1) \
.filter("output.temperature", ">", 300) \
.select("input.acoustic_length", "output.temperature", "output.heat_flux") \
.sort("output.temperature", asc=True) \
.limit(20)
response = query.execute()
4. Pagination
# Iterate over all results
for result in results.query("abinit") \
.filter("output.energy", "<", 0) \
.select("output.energy", "output.forces") \
.paginate(per_page=50):
print(result)
5. Download Files
# Download a specific output field
file_content = results.download(
tool="abinit",
squid="simulation_id_here",
field="output.wavefunction"
)
with open("wavefunction.dat", "wb") as f:
f.write(file_content)
Testing Without Installation
All examples include path configuration for testing without installation:
cd examples
python3 01_basic_search.py
API Reference
Results Class
query(tool, simtool=False)
Create a Query builder for a tool.
get_tools(simtool=False, description_active=False)
Get list of available tools.
get_tool_detail(tool, revision=0, simtool=False)
Get tool schema and metadata.
search(tool, filters, results_fields, ...)
Direct search (or use Query builder).
download(tool, squid, field=None, ...)
Download files or output fields.
Query Class
Methods (all return self for chaining):
filter(field, op, value)- Add filter conditionselect(*fields)- Specify fields to returnlimit(limit)- Set result limitoffset(offset)- Set pagination offsetsort(field, asc=True)- Set sort orderexecute()- Execute the querypaginate(per_page=50)- Iterate over all results
Valid Operations
=- Equal!=- Not equal>- Greater than<- Less than>=- Greater than or equal<=- Less than or equallike- Pattern matchingin- In list
Examples Directory
See the examples/ directory for complete examples:
01_basic_search.py- Basic query usage02_advanced_filtering.py- Multiple filters and sorting03_downloading_files.py- File downloads04_pagination.py- Automatic pagination
License
See LICENSE file for details.
Metadata
Release files for nanohub-results 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nanohub_results-1.0.0.tar.gz | 29.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nanohub_results-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.1 kB
Release files / nanohub_results-1.0.0.tar.gz
| Download URL | nanohub_results-1.0.0.tar.gz |
|---|---|
| Size | 29.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ebf324b57666fc3c9260d0d14bebfad4afdcd6a1d175423656ad74240e25ded
|
|
BLAKE2b-256 checksum How to use checksums |
f9878544f1c034fd3dc0919ef443ed19607b12affae3cb0a4358af96e055c0b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Release files / nanohub_results-1.0.0-py3-none-any.whl
| Download URL | nanohub_results-1.0.0-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f3db23d03124a81e62a72657aa9a42f7ab7baeb145fcdc58e3b67c5655af332
|
|
BLAKE2b-256 checksum How to use checksums |
330628c509fc6aebfc136bc6cd6c124a361181a620e2b0bf301b30db6b4cd6b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Security for nanohub-results 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.