Skip to content

Updating from Oracle - #69

Merged
eloise-nebula merged 3 commits into
mainfrom
update_db
Aug 18, 2026
Merged

Updating from Oracle#69
eloise-nebula merged 3 commits into
mainfrom
update_db

Conversation

@williamColocho

Copy link
Copy Markdown
Collaborator

Fix oracle_db() and clean up lcls_elements.csv includes added/updated data for LCLS-II-HE areas

Problems Fixed

1. KeyError: 'area' in oracle.py

_Inserter._rows() used mixed-case schema column names (e.g. "Area") as keys
on the row dict, but _parse_csv() lowercases all CSV headers, producing keys
like "area". This caused a KeyError on every call to oracle_db().

2. Wrong header row read in lcls_elements.py

The CSV has a group header on row 1 (e.g. "EPICS Channel Access Device", etc.)
and the actual column names on row 2. _parse_csv() was consuming row 1 as
column names, misaligning all field mappings and producing broken row dicts.

Interim fixes (3, 4) to lcls_elements.csv: SLACPROD maintainer has been contacted and changes will be made permanent there. Fixing here in the mean time:

3. Duplicate BX31T entry in lcls_elements.csv

Element "BX31T" appeared twice in the CSV with identical fields except for the
Barcode column (4580T vs BX31T). This caused a UNIQUE constraint failure on
insert into lcls_elements.sqlite3. The duplicate row (Barcode = BX31T) has
been removed. The upstream CSV source will be fixed separately.

4. Missing Control System Names for L0A, L0B, L1X

The active entries for L0A, L0B, and L1X had empty Control System Name fields.
The correct values were present on their inactive counterparts (L0A___, L0B___,
L1X___) and have been copied over.

Changes

slac_db/oracle.py

  • _Inserter._rows line 163: r[c.name] -> r[c.name.lower()]
    Schema column names are mixed-case; parser row dicts use lowercase keys.

slac_db/create/lcls_elements.py

  • _parse_csv: add next(reader) before reading column names to skip the
    group header row (row 1) and use the actual column names on row 2.

slac_db/package_data/lcls_elements.csv

  • Removed duplicate BX31T row (kept Barcode=4580T, removed Barcode=BX31T).
  • L0A: set Control System Name = ACCL:IN20:300 (copied from L0A___).
  • L0B: set Control System Name = ACCL:IN20:400 (copied from L0B___).
  • L1X: set Control System Name = ACCL:LI21:180 (copied from L1X___).

Testing

Verified with:
slac_db.create.oracle_db() # completes without error

@eloise-nebula

Copy link
Copy Markdown
Collaborator

Hi William, I just merged this PR:
#71

It should help fix some of the tests that are failing here. Could you pull from main and make sure the tests pass? Thank you!

@eloise-nebula eloise-nebula left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you William!

@eloise-nebula
eloise-nebula merged commit c646d4d into main Aug 18, 2026
6 checks passed
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.

2 participants