Skip to main content

This a python package to run and download submitted files on RSHub

Project description

Toolbox overview

  • submit_jobs.run: submit a simulation job to the RSHub service.
  • submit_jobs.check_completion: poll a job’s task status/path.
  • loader = load_file.load_file: helper class to list, download, and load outputs.
  • loader.list_files: list available outputs filtered by expected extension.
  • loader.load_outputs: load or download outputs (auto memory/disk or forced).

RSHub client quickstart

This package lets you submit simulation jobs and fetch the resulting files from the RSHub service.

Prerequisites

  • Python 3.8+ with requests, pandas, scipy, h5py, and tqdm available.

Function 1: Submit a job and job status

from rshub.submit_jobs import run, check_completion

payload = {
    "token": "YOUR_TOKEN",
    "project_name": "demo_project",
    "task_name": "snow_run_001",
    # ...other inputs expected by the backend...
}

# Fire off the job
resp = run(payload)
print("Submission response:", resp)

# Later, poll status
status = check_completion(payload["token"], payload["project_name"], payload["task_name"])
print("Task status:", status["task_status"])
  • run posts your JSON payload to the service and returns the parsed JSON on success.

Function 2: Load outputs

load_file.load_file handles listing outputs, downloading files, and loading datasets.

Basic example: load one output file

from rshub.load_file import load_file

loader = load_file(
    token="YOUR_TOKEN",
    project_name="demo_project",
    task_name="snow_run_001",
    scenario_flag="snow",
    algorithm="qms",
    output_var="tb",
)

# Load and return the dataset (auto memory/disk)
data = loader.load_outputs(fGHz=16.7, inc_ang=40)
print(data.keys())  # inspect variables in the file

Full input lists

from rshub.load_file import load_file

loader = load_file(
    token="YOUR_TOKEN",
    project_name="demo_project",
    task_name="snow_run_001",
    scenario_flag="snow",      # matches output_info.csv
    algorithm="qms",
    output_var="tb",
    size_threshold_mb=50,      # switch to disk download above this size
    chunk_size=8192,           # streaming chunk size when downloading
    show_progress=True,        # show tqdm progress for large downloads
)

Constructor inputs (load_file)

  • token, project_name, task_name: identify the job; required for auth/path lookup.
  • scenario_flag, algorithm, output_var: select the output filename.
  • (optional) size_threshold_mb: MB cutoff to switch from in-memory load to disk download. Default: 50.
  • (optional) chunk_size: bytes per stream chunk when downloading large files. Default: 8192.
  • (optional) show_progress: whether to display a tqdm progress bar during large downloads. Default: True

List available output files

print(loader.list_files())

Load an output file

Path1: load using frequency and incident angle

# Autodetect memory vs disk based on size; 
data = loader.load_outputs(fGHz=16.7, inc_ang=40)
  • fGHz: frequency placeholder for filename patterns.
  • inc_ang: incidence angle placeholder for filename patterns.

Path2: load using filename output from load_outputs

filelists = loader.list_files() 
filename=filelists[0]
data = loader.load_outputs(filename)
  • filename: output filename with extension

Other optinal inputs

# Force a strategy
data_mem = loader.load_outputs(fGHz=16.7, inc_ang=40, force_method="memory")
data_disk = loader.load_outputs(fGHz=16.7, inc_ang=40, force_method="disk")
  • (experimental) var: single variable or space-separated names to extract from the loaded data.
  • force_method: "memory" or "disk" to override size-based strategy.
  • download_path: directory path; if set, performs download-only behavior for matching files.

Download-only outputs (wildcard patterns)

loader.load_outputs(download_path="downloads/", fGHz=16.7, inc_ang=40)
  • download_path: local path to download all outputs.

Check error messages for a job

loader.load_error_message()  # prints contents of Job/error.txt if present

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rshub-0.3.3.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rshub-0.3.3-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file rshub-0.3.3.tar.gz.

File metadata

  • Download URL: rshub-0.3.3.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for rshub-0.3.3.tar.gz
Algorithm Hash digest
SHA256 a27ae69307e66943220f85ab7cba6294e143c4a3441318f5d44bb42974399088
MD5 347d6655f8bc4e3e3b6e1e7a383a3e1d
BLAKE2b-256 75e4ac0f2a3050fea3a68ac2eeaeb9d0e99e16b382d2bb7b11de4aa64f14e0b8

See more details on using hashes here.

File details

Details for the file rshub-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: rshub-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for rshub-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7307ec7ae69bf1d0f871ff00b47722c4731d2e6c268dd8d338e2c01f33575dfd
MD5 106e452d1a0b53622416a13d2faae171
BLAKE2b-256 73bfb79375b2fd27f322bf34c0cda1743e4dc2f86634c7b8811d42bb6e5dc437

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page