Skip to content

Commit 818a517

Browse files
authored
Revert "ads"
1 parent 654bd2a commit 818a517

3 files changed

Lines changed: 18 additions & 270 deletions

File tree

scripts/inbox_to_schema.py

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -531,35 +531,25 @@ def plan_changes(
531531
effective_class, slot_origin, class_origin,
532532
changes, reporter,
533533
)
534-
elif derived_name in get_all_class_slots(schema, effective_class):
535-
# Slot already belongs to the subclass hierarchy (its own
536-
# slots: list or a mixin) and cannot be modified via the
537-
# inbox workflow. Skip silently — these rows are
538-
# structural display information from the Excel
534+
else:
535+
# Slot belongs to the subclass hierarchy (mixin,
536+
# attribute, or imported slot) and cannot be modified
537+
# via the inbox workflow. Skip silently — these rows
538+
# are structural display information from the Excel
539539
# generator, not editable fields.
540540
reporter.info(
541541
sheet_title, f"slot '{label}'",
542542
f"Skipped: belongs to sub-class `{effective_class}` "
543543
f"and is not modifiable via the inbox workflow "
544544
f"(edit the YAML directly).",
545545
)
546-
else:
547-
# Unknown slot assigned to a domain class that does not
548-
# already define it → a genuinely new slot to be added to
549-
# that subclass (e.g. anode/cathode on ElectrochemicalReactor).
550-
# _plan_new_slot resolves the owner class from the domain.
551-
_plan_new_slot(
552-
row, sheet_title, schema_class,
553-
schema, class_origin, slot_origin, label_to_slot,
554-
label_to_class, changes, reporter,
555-
)
556546

557547
else:
558548
# ── Unknown label + empty domain → new top-level slot ──
559549
_plan_new_slot(
560550
row, sheet_title, schema_class,
561551
schema, class_origin, slot_origin, label_to_slot,
562-
label_to_class, changes, reporter,
552+
changes, reporter,
563553
)
564554

565555
elif row_type == "class":
@@ -788,31 +778,23 @@ def _plan_new_slot(
788778
class_origin: dict[str, Path],
789779
slot_origin: dict[str, Path],
790780
label_to_slot: dict[str, str],
791-
label_to_class: dict[str, str],
792781
changes: list,
793782
reporter: Reporter,
794783
) -> None:
795784
label = row["label"]
796785
domain = row["domain"]
797786
slot_name = _label_to_slot_name(label)
798787

799-
# Resolve the class that will own the new slot:
800-
# • empty domain → the sheet's top-level data class (schema_class)
801-
# • non-empty domain → the named subclass (e.g. ElectrochemicalReactor),
802-
# added to that class exactly like the top-level case.
788+
# Only top-level new slots are supported (domain must be empty)
803789
if domain:
804-
owner_class = label_to_class.get(domain) or domain
805-
if owner_class not in schema.get("classes", {}):
806-
reporter.error(
807-
sheet, f"new slot '{label}'",
808-
f"The domain `{domain}` is not a recognised class. "
809-
f"Set the domain column to an existing class label, or leave it "
810-
f"empty to add a top-level slot.",
811-
hint="Look at the class rows in this sheet for valid domain names.",
812-
)
813-
return
814-
else:
815-
owner_class = schema_class
790+
reporter.error(
791+
sheet, f"new slot '{label}'",
792+
f"New slots may only be added at the top level of a data class "
793+
f"(the **domain** column must be empty). Got domain=`{domain}`.",
794+
hint="To add a slot inside a subclass, edit the YAML directly. "
795+
"For a top-level slot, leave the domain column empty.",
796+
)
797+
return
816798

817799
# Name conflict: same derived name as an existing slot
818800
if slot_name in schema.get("slots", {}):
@@ -845,16 +827,16 @@ def _plan_new_slot(
845827
)
846828
return
847829

848-
target = class_origin.get(owner_class, SCHEMA_DIR / MODULE_FILES[-1])
830+
target = class_origin.get(schema_class, SCHEMA_DIR / MODULE_FILES[-1])
849831
reporter.info(
850832
sheet, f"new slot `{slot_name}`",
851-
f"Will add `{slot_name}` to `{owner_class}`.",
833+
f"Will add `{slot_name}` to `{schema_class}`.",
852834
)
853835
changes.append({
854836
"type": "slot_add",
855837
"name": slot_name,
856838
"label": label,
857-
"schema_class": owner_class,
839+
"schema_class": schema_class,
858840
"range": range_val,
859841
"mro": mro,
860842
"description": row["description"],

src/coremeta4cat/schema/coremeta4cat_reaction_ap.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ classes:
166166
Electrochemical reactor used in electrocatalytic experiments, including
167167
H-cells, flow cells, and membrane electrode assemblies.
168168
169-
slots:
170-
- anode
171-
- cathode
172169
CSTR:
173170
is_a: ChemicalReactor
174171
class_uri: VOC4CAT:0007019
@@ -319,11 +316,3 @@ slots:
319316
required: true
320317
multivalued: true
321318
inlined_as_list: true
322-
anode:
323-
description: The electrode where oxidation occurs in an electrochemical cell. It is the positive electrode in an electrolytic cell, while it is the negative electrode in a galvanic cell.
324-
slot_uri: VOC4CAT:0007254
325-
required: true
326-
cathode:
327-
description: The electrode where reduction occurs in an electrochemical cell. It is the negative electrode in an electrolytic cell, while it is the positive electrode in a galvanic cell.
328-
slot_uri: VOC4CAT:0007255
329-
required: true

tests/test_inbox_to_schema.py

Lines changed: 0 additions & 223 deletions
This file was deleted.

0 commit comments

Comments
 (0)