Closed pkalita-lbl closed 2 years ago
That's a good catch. I didn't think that generate_patterns
would have been used outside of this project. Although, oddly that's an unused import in the linkml
project. Still, you make a valid point that we shouldn't just yank away an ostensibly public function without warning. I will re-create a generate_patterns
method that delegates to PatternResolver
.
The changes look good to me @pkalita-lbl.🚀 Good catch, about structured patterns not getting expanded when they are applied to slot_usage and attributes properties on classes.
These changes extend the functionality of
SchemaView.materalize_patterns
to also include class slot usage and attributes. As a side effect it also slightly changes howstructured_pattern
s are resolved.Previously there was a utility method called
generate_patterns
which iterated over all of a schema's slots to precompute all of the resolved patterns. Thenmaterialize_patterns
would iterate over the schema's slots again and populate the schema with the results fromgenerate_patterns
.With these changes,
materialize_patterns
iterates over slots and classes to account forslot_usage
andattributes
. In order to not duplicate logic,generate_patterns
has been replaced by a class calledPatternResolver
which expandsstructured_pattern
s on the fly, caching results as it goes. The central logic of how the expansion is done is unchanged.Fixes #203