Skip to content

Sasbdb load#3913

Open
wpotrzebowski wants to merge 14 commits into
mainfrom
sasbdb_load
Open

Sasbdb load#3913
wpotrzebowski wants to merge 14 commits into
mainfrom
sasbdb_load

Conversation

@wpotrzebowski

@wpotrzebowski wpotrzebowski commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Description

This branch adds Load from SASBDB: users can enter a SASBDB dataset ID, fetch metadata and intensity data from the SASBDB REST API, download a local copy, load it through the existing File data pipeline, and enrich the loaded Data1D objects with SASBDB-derived metadata (sample, instrument, publication, Rg, I(0), Dmax, MW, etc.) where the API provides them.

Implementation highlights

  • sasbdb_api: HTTP client for https://www.sasbdb.org/rest-api using requests — metadata fetch, URL discovery for intensity files, streamed download to a temp path, robust parsing into SASBDBDatasetInfo (dataclass). Validates 7-character entry codes (e.g. SASDN24) before calling the API; does not guess download URLs when metadata lacks a file link.
  • SASBDBDownloadDialog: Simple UI (dataset ID, Download, progress, status, Help/Cancel); validates ID up front; on success returns filepath + parsed info for loading.
    sasbdb_loader: Loads the downloaded file via filesWidget.readData, then populate_metadata() merges API fields into data.sample, data.run, data.instrument, data.title, and meta_data['SASBDB_*'] keys. Surfaces a warning if readData returns no datasets.
  • sasbdb_display: Formats metadata for dialog status, logging, and Data Explorer summary panels. Dict-line cleanup applies only to SASBDB datasets so non-SASBDB summaries are unchanged.
  • GuiManager.actionLoad_SASBDB: Wired from File → Load from SASBDB… (MainWindowUI.ui); thin handler that opens the dialog and delegates to load_downloaded_dataset.
  • GuiUtils: retrieveData1d / retrieveData2d call append_sasbdb_data_summary() when SASBDB_code is present — SASBDB display logic lives in the SASBDB package, not in GuiUtils.
  • Docs: User menu/tools Sphinx sources and in-app help sasbdb_download_help.rst.

How Has This Been Tested?

  • Manual (recommended):
    1. File → Load from SASBDB; enter a known valid SASBDB entry ID.
    2. Confirm download completes, data appears in Data Explorer, and plots load as for a normal ASCII/dat file.
    3. Inspect dataset details / summary text for SASBDB fields (code, Rg, publication, etc.) when returned by the API.
    4. Try an invalid ID and confirm a clear error (404 / network).
    5. Offline: confirm failure is handled without crashing (message or log).

Review Checklist

  • Security / network: Timeouts, HTTPS-only usage, and user-visible errors for failed downloads are acceptable.
  • Metadata mapping: SASBDB → Sample / Source / meta_data keys do not break loaders or perspectives.
  • SASBDBDownloadDialogUI.ui is accompanied by regenerated Python UI (convertUI.py / project build) if required.
  • Documentation (menu_bar.rst, tools.rst, sasbdb_download_help.rst) matches the menu label and workflow.
  • requests remains available in the installed dependency set for end users (not only dev tooling).

Documentation (check at least one)

  • There is nothing that needs documenting
  • Documentation changes are in this PR
  • There is an issue open for the documentation (link?)

Installers

  • There is a chance this will affect the installers, if so
    • Windows installer (GH artifact) has been tested (installed and worked)
    • MacOSX installer (GH artifact) has been tested (installed and worked)
    • Wheels installer (GH artifact) has been tested (installed and worked)

Licensing (untick if necessary)

  • The introduced changes comply with SasView license (BSD 3-Clause)

@wpotrzebowski
wpotrzebowski marked this pull request as ready for review July 15, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant