Skip to main content

Nanohub remote

Stats

Latest Release
PyPI Downloads
Nanohub Tutorial
A set of tools/apps to run on nanohub

Installation

pip install nanohub-remote

Usage

Basic Authentication

import nanohubremote as nr

# Option 1: OAuth Password Grant (requires web application)
auth_data = {
  'client_id': 'XXXXXXXX',
  'client_secret': 'XXXXXXXX',
  'grant_type': 'password',
  'username': 'your_username',
  'password': 'your_password'
}

# Option 2: Personal Access Token (recommended)
auth_data = {
  'grant_type': 'personal_token',
  'token': 'your_personal_token'
}

# to get username and password, register on nanohub.org (https://nanohub.org/register/)
# to get client id and secret, create a web application (https://nanohub.org/developer/api/applications/new), use "https://127.0.0.1" as Redirect URL
# to get a personal token, go to https://nanohub.org/developer/api/tokens

# Create a session
session = nr.Session(auth_data)

# Or use as a context manager (recommended - automatically cleans up resources)
with nr.Session(auth_data) as session:
    # Your code here
    pass

Session Configuration

The Session class supports advanced configuration options:

session = nr.Session(
    auth_data,
    url="https://nanohub.org/api",  # Custom API URL
    timeout=10,                       # Request timeout in seconds (default: 5)
    max_retries=5,                    # Maximum retries for failed requests (default: 3)
    pool_connections=20,              # Connection pool size (default: 10)
    pool_maxsize=20                   # Max pool size (default: 10)
)

HTTP Methods

The Session class provides methods for all standard HTTP verbs:

with nr.Session(auth_data) as session:
    # GET request
    response = session.requestGet('tools/list')
    tools = response.json()

    # POST request with form data
    response = session.requestPost('endpoint', data={'key': 'value'})

    # POST request with JSON
    response = session.requestPost('endpoint', json={'key': 'value'})

    # PUT request
    response = session.requestPut('resource/123', json={'status': 'updated'})

    # DELETE request
    response = session.requestDelete('resource/123')

    # PATCH request
    response = session.requestPatch('resource/123', json={'field': 'new_value'})

Features

  • Connection Pooling: Reuses HTTP connections for better performance
  • Automatic Retries: Automatically retries failed requests (configurable)
  • Token Management: Handles OAuth token refresh automatically
  • Context Manager: Use with statement for automatic resource cleanup
  • Persistent Headers: Headers are maintained across all requests

Development

Running Tests

# Install development dependencies
pip install -r requirements-dev.txt

# Run all tests
pytest

# Run with coverage
pytest --cov=nanohubremote --cov-report=html

# Run specific test file
pytest tests/test_session.py

See tests/README.md for detailed testing documentation.

Available Nanohub Points

Tools

TOOLNAME = '' # valid Nanoohub tool name e.g. pntoy
tool = nr.Tool(auth_data)

# Get Available input parameters
params = tool.getToolParameters(TOOLNAME)

# Submit a simulation experiment
job_id = tool.submitTool(params)

# Check Status
status = tool.checkStatus(job_id['job_id'])

# Get Results
results = tool.getResults(job_id['job_id'])

# Submit an wait for results
results = tool.submitTool(params, wait_results=True)

Sim2Ls

TOOLNAME = '' # valid Nanoohub tool name e.g. pntoy
s2l = nr.Sim2L(auth_data)

# Get Available input parameters
params = s2l.getToolParameters(TOOLNAME)

# Submit a simulation experiment
job_id = s2l.submitTool(params)

# Check Status
status = s2l.checkStatus(job_id['job_id'])

# Get Results
results = s2l.getResults(job_id['job_id'])

# Submit an wait for results
results = s2l.submitTool(params, wait_results=True)

Metadata

Release files for nanohub-remote 0.2.3

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

Source distribution (sdist)

Source distribution for nanohub-remote 0.2.3
File Size Uploaded Provenance Actions
nanohub_remote-0.2.3.tar.gz 512.6 kB Without provenance Details for nanohub_remote-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nanohub-remote 0.2.3
File Interpreter ABI Platform Actions
nanohub_remote-0.2.3-py3-none-any.whl Python 3 none any Details for nanohub_remote-0.2.3-py3-none-any.whl

Total release size: 546.2 kB

Release files / nanohub_remote-0.2.3.tar.gz

Download URL nanohub_remote-0.2.3.tar.gz
Size 512.6 kB
Tags Source
SHA-256 checksum
How to use checksums
426e4b434224e5322e77a9f39bb5df0c4fbebaaafeefaa180f8c697a5bd97e34
BLAKE2b-256 checksum
How to use checksums
527caace1083c3a2800547bf014f81c871ef79d0d27db096f87952eff0530cd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / nanohub_remote-0.2.3-py3-none-any.whl

Download URL nanohub_remote-0.2.3-py3-none-any.whl
Size 33.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3bfdbd3dd7b36c7d155eab1e3f78feb6727e2ef55df1e6b5adc86f609314237
BLAKE2b-256 checksum
How to use checksums
abfc815206ce111f090585c358662c6a4ecb9056f3584aa58425d71d40ada359
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for nanohub-remote 0.2.3

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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