Skip to content

Sasbdb load#3913

Draft
wpotrzebowski wants to merge 4 commits intomainfrom
sasbdb_load
Draft

Sasbdb load#3913
wpotrzebowski wants to merge 4 commits intomainfrom
sasbdb_load

Conversation

@wpotrzebowski
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).
  • SASBDBDownloadDialog: Simple UI (dataset ID, Download, progress, status, Help/Cancel); on success returns filepath + parsed info for loading.
  • GuiManager.actionLoad_SASBDB: Wired from File → Load from SASBDB (MainWindowUI.ui); calls filesWidget.readData, then _populateSASBDBMetadata to merge API fields into data.sample, data.run, data.instrument, data.title, and meta_data['SASBDB_*'] keys for downstream display.
  • GuiUtils: Extends dataset summary text (e.g. Data Explorer / details) with a SASBDB metadata block when SASBDB_code (and related keys) are present.
  • Docs: User menu/tools Sphinx sources and in-app help sasbdb_download_help.rst.

Dependencies

  • requests (already listed in build_tools/requirements.txt for the project).
  • Network access at runtime to reach sasbdb.org for metadata and file download.

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).
  • Automated: No dedicated unit tests for sasbdb_api / download dialog were added on this branch; consider mocking HTTP for CI in a follow-up.

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)

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