Skip to content

Conversation

@tanaya-mankad
Copy link
Contributor

  1. Changed "Data Type" to "Type" inside schema and schema parsing, but not inside core.schema.yaml, so that we can still have the syntax
    String: Object Type: "Data Type"
  2. Allow 232-compatible descriptor-based type declarations alongside shorthand symbolic declarations. This change majorly benefitted from adding named groups in schema.py's group types and constraint types, and using those named groups in the json and cpp generators.
  3. In order to support repeated group names, we'll use the regex module instead of the built-in re.

@tanaya-mankad tanaya-mankad self-assigned this Oct 1, 2025


# Module functions
def unname_group(expression: RegularExpressionPattern) -> str:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a great function name, but short.

Copy link
Member

Choose a reason for hiding this comment

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

remove_named_regex_groups?

Copy link
Member

Choose a reason for hiding this comment

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

...or maybe this should be a member function of RegularExpressionPattern called normalize, cleaned, remove_groups?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can make it a static or class method, then we can make it a member if/when the "base class" is implemented.

if this < other:
dependency_graph.add_edge(this, other)
dependency_graph.remove_nodes_from(list(networkx.isolates(dependency_graph)))
# dependency_graph.remove_nodes_from(list(networkx.isolates(dependency_graph)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure why I was removing unconnected nodes; this was causing the Courier declaration to go missing!

entry += f"{self._indent}\t{e},\n"
entry += f"{self._indent}\tUNKNOWN\n{self._indent}{self._closure}"
if "UNKNOWN" not in self._enumerants:
entry += f"{self._indent}\tUNKNOWN\n"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ClimateInformation::DataSourceType already has an UNKNOWN enumerant in the schema. We've been adding one in all the other enums just for the cpp code. So, now we check first.

Copy link
Member

Choose a reason for hiding this comment

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

hmmm...do we remember why? This might be worth looking into more later. We can make an issue for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My answer is usually, "Chip".

Copy link
Contributor Author

@tanaya-mankad tanaya-mankad left a comment

Choose a reason for hiding this comment

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

See comments on changes.

)
# else:
# raise Exception(f"Unrecognized Object Type, \"{object_type}\" in {self.file_path}")
for group in self.data_groups.values():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Separated the extraction of elements into its own loop, in order to have all DataGroup objects available when any element is populated. This allows for an element's type to find its defining DataGroup and see if custom attributes should be applied based on that DataGroup's parents and/or templates.

@tanaya-mankad
Copy link
Contributor Author

@nealkruis, this is ready for re-review. We should merge this before the recent PR I started with custom-cpp-gen-path.

Comment on lines 44 to 46
# Module functions


Copy link
Member

Choose a reason for hiding this comment

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

Looks like a remnant?


self.data_element_name = match.group(1) # TODO: Named groups?
self.data_element_value = match.group(5)
self.data_element_name = match.group("DataElementName")
Copy link
Member

Choose a reason for hiding this comment

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

❤️

self.dictionary = data_group_dictionary
self.parent_schema = parent_schema
self.parent_template: DataGroupTemplate | None = self._assign_template(
self.dictionary.get("Data Group Template", "")
Copy link
Member

Choose a reason for hiding this comment

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

If a template name doesn't exist in the schema (even ""), we should raise an exception or log an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand this - self.parent_template is allowed to be None because not every DataGroup has one.

Copy link
Member

Choose a reason for hiding this comment

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

What happens if a user has a Data Group Template called ""? That should raise an error since that Data Group Template doesn't exist.

Or if they user references a Data Group Template name that doesn't exist, I think the current code would just assign it to None and go along its happy way. Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see - None isn't the right answer. Fixed!

submodule_urls: list[str] = []

config_file = Path(self.root_directory / "cpp" / "config.yaml").resolve()
config_file = Path(self.root_directory / "cpp" / "0config.yaml").resolve()
Copy link
Member

Choose a reason for hiding this comment

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

Looks like a typo?

dodo.py Outdated
"name": name,
"task_dep": [f"validate_schemas:{name}", f"generate_json_schemas:{name}", f"validate_example_files:{name}"],
"file_dep": [schema.file_path for schema in example.schemas]
"file_dep": [schema.schema.file_path for schema in example.schemas]
Copy link
Member

Choose a reason for hiding this comment

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

I'm slightly bothered by "schema.schema". Why is it necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's unfortunate. We can do it a different way, but the reason this exists is because of how lattice.py changed its interaction with what's now schema.py. Used to be that the schema class held its own json_schema_path, meta_schema_path, and cpp_path. Those no longer exist, so I encapsulated them with the schema in a dataclass called SchemaSupport.
Lattice.schema is now a list[SchemaSupport] instead of a list[Schema].
It's a hack for sure, but it's also structurally sound!

Copy link
Member

Choose a reason for hiding this comment

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

I see. We need a structure to relate the various paths with the Schema since the Schema class doesn't actually know about these paths. I think we just need better names then.

Copy link
Member

Choose a reason for hiding this comment

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

What about Lattice.schema_supports?

Copy link
Member

Choose a reason for hiding this comment

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

Ooops. I see you already changed it to schema_info. I'm okay with that. But the CI is now angry.

@nealkruis nealkruis merged commit 9aa8adc into main Dec 23, 2025
14 checks passed
@nealkruis nealkruis deleted the additional-232-enhancements branch December 23, 2025 16:33
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.

3 participants