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.

load submitted parameters for a job

params = loader.load_parameters()
# prints project parameters

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.4.tar.gz (11.4 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.4-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rshub-0.3.4.tar.gz
  • Upload date:
  • Size: 11.4 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.4.tar.gz
Algorithm Hash digest
SHA256 bdc18ac72d9e4337d006b604279538ba8db2646590f1de1498c1f20c391612b1
MD5 cf0e31b8f26f8bff1b0aeb11fe802f68
BLAKE2b-256 f6f4f305790f77da49796444b41f5e686ee8a695ecdc0dd580d336c9410086d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rshub-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 11.0 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 08186c6707a2243e78622214d7401ecacc5588eff09e3b8ac58032665eb1da61
MD5 6c0f845928ea7b5c7f1c8831500b3d7d
BLAKE2b-256 6ddc0280881ed923ce0f8697aa240d7d1c4fec64e3a8ab5857a18f309a0742b0

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