Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up object and module organization #225

Merged
merged 4 commits into from
Aug 30, 2022
Merged

Conversation

tlento
Copy link
Contributor

@tlento tlento commented Aug 26, 2022

We have a number of slightly wonky organizational artifacts in our
codebase which have been cropping up as circular imports of late.
Most recently, issues with conversion between WhereClauseConstraint
and SpecWhereClauseConstraint are blocking update and merge on
#153 , but that's not the only issue we've been encountering.

This PR does the following in order to tidy things up and bring us
a bit closer to the layout described in #214:

  • Move WhereClauseConstraint conversion out of the query parser
  • Move AggregationType to a root module
  • Split NonAdditiveDimensionParams into a model object/spec pair
    • Clean up naming and update plan files

@tlento
Copy link
Contributor Author

tlento commented Aug 26, 2022

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

We occasionally need to convert WhereClauseConstraint objects to
SpecWhereClauseConstraint objects. For historical reasons
this logic was held in the MetricFlowQueryParser, but keeping
it there does not make a lot of organizational sense. Worse, it
sets up potential circular dependencies, as it forces the query
parser to depend on our semantic containers, and the dataflow
plan builder to depend on the query parser.

Here we split this helper into its own independent class. We cannot
move it onto either the source or target classes because of other
concerns around possible circular dependencies, which we have
documented in the new module.
The AggregationType enum was included with the Measure model object
because that was where it was first needed, but its utility is quite
a bit broader than as a model enumeration. Since its current location
leads to potential circular imports, and additional aggregation
properties (such as additiveness) might be coming in the future, we
move it to a root aggregation_properties module.
Specs are meant to be relatively mutable constructs that can change
depending on query constraints, while model objects are meant to be
consistent to the user defined metric model. Therefore, we split
the active dataflow state operations into a separate
NonAdditiveDimensionSpec class, and populate its properties from
the NonAdditiveDimensionParams model object.
This nomenclature is a little confusing, so we name all of the
variables pointing at NonAdditiveDimensionSpec accordingly.
@tlento tlento force-pushed the add-semantic-container-protocols branch from 78ffcdb to c5eb2f9 Compare August 26, 2022 18:17
@tlento tlento temporarily deployed to DW_INTEGRATION_TESTS August 26, 2022 19:08 Inactive
@tlento tlento temporarily deployed to DW_INTEGRATION_TESTS August 26, 2022 19:08 Inactive
@tlento tlento temporarily deployed to DW_INTEGRATION_TESTS August 26, 2022 19:08 Inactive
Copy link
Contributor

@WilliamDee WilliamDee left a comment

Choose a reason for hiding this comment

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

this looks great! Thank you for cleaning everything!

SIDE NOTE: we will need to make some changes to our internal SourceNodeBuilder to accommodate the change from NonAdditiveDimensionParameters to NonAdditiveDimensionSpec

@@ -0,0 +1,39 @@
from __future__ import annotations
Copy link
Contributor

Choose a reason for hiding this comment

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

what if we had like a metricflow/model/properties/ directory that stores these? I'm not aware of the best practices, but personally I like how we have most things organized in their respective directories rather than being in the root directory.

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 think that'd be fine, although I pulled these to root because I think of them as being on the level of specs and suchlike. To be honest I thought about moving those into a sub-directory as well, but decided not to get too carried away, so I'm open to some simple file move reorganization PRs.

Base automatically changed from add-semantic-container-protocols to main August 30, 2022 01:55
@tlento tlento merged commit b345062 into main Aug 30, 2022
@tlento tlento deleted the streamline-dependencies branch August 30, 2022 02:01
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.

Semantic conversions between objects and specs leads to circular import dependencies
2 participants