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

refactor: time series collection, resource handling #612

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

jsolaas
Copy link
Contributor

@jsolaas jsolaas commented Sep 19, 2024

Have you remembered and considered?

  • I have remembered to update documentation
  • I have remembered to update manual changelog (docs/docs/changelog/next.md)
  • I have remembered to update migration guide (docs/docs/migration_guides/)
  • I have committed with BREAKING: in footer or ! in header, if breaking
  • I have added tests (if not, comment why)
  • I have used conventional commits syntax (if you squash, make sure that conventional commit is used)
  • I have included the Jira issue ID somewhere in the commit body (ECALC-XXXX)

Why is this pull request needed?

Previously, time_series_collection.py and
time_series_collection_mapper.py did a lot of stuff. In addition to dealing with the resource data and validating that, the yaml data was also validated. As this was bundled it was difficult to reuse some of the logic. Each separate step should now be available by using the correct class.

What does this pull request change?

Create domain objects for TimeSeriesResource, TimeSeriesCollection++. This should make the behavior more clear, and provide more flexibility in the future.

Issues related to this change:

def get_time_series(self, reference_id: str) -> TimeSeries:
try:
return TimeSeries(
reference_id=f"{self.name};{reference_id}",
Copy link
Collaborator

Choose a reason for hiding this comment

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

a bit ambigious when both "name+column_name" and column_name is referenced to as reference_id, in different contexts ... can we call it column_name/id here? and that a reference id is "timeseriescollectionname + column name", to get things straight?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

collection_id and time_series_id? We started using reference_id for resources in the api, in that context it's the name of the resource.

I agree it's confusing, the way I see it it's just an id, and an id is expected to have meaning only within the context. I.e. time_series.id and collection.id. But it's always useful to then name that id more specifically in other contexts, where you only have the id (time_series_id and collection_id, etc).

Copy link
Collaborator

@TeeeJay TeeeJay left a comment

Choose a reason for hiding this comment

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

very nice job - much better code than it was :)

@jsolaas jsolaas force-pushed the refactor/time_series_collection branch 2 times, most recently from 24c4650 to a31867b Compare September 19, 2024 13:40
@jsolaas jsolaas marked this pull request as ready for review September 19, 2024 13:43
@jsolaas jsolaas requested a review from a team as a code owner September 19, 2024 13:43
@jsolaas jsolaas force-pushed the refactor/time_series_collection branch 5 times, most recently from ee2d5f6 to 9072503 Compare September 23, 2024 06:47
self.header = header
self.row = row
super().__init__(
"Invalid column",
Copy link
Collaborator

Choose a reason for hiding this comment

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

possible to indicate which column that is invalid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's handled in the message currently. Not sure what to make of the title in these errors vs message.

from libecalc.presentation.yaml.yaml_keywords import EcalcYamlKeywords


class InvalidTimeSeriesResource(InvalidResource):
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we use the convention for expceptions to end in Exception or Error? I think we should

Create domain objects for TimeSeriesResource, TimeSeriesCollection++.
This should make the behavior more clear, and provide more flexibility
in the future.

Previously, time_series_collection.py and
time_series_collection_mapper.py did a lot of stuff. In addition to
dealing with the resource data and validating that, the yaml data was
also validated. As this was bundled it was difficult to reuse some of
the logic. Each separate step should now be available by using the
correct class.
@jsolaas jsolaas force-pushed the refactor/time_series_collection branch from 9072503 to 36dc739 Compare September 23, 2024 10:11
@jsolaas jsolaas merged commit cf80ce8 into main Sep 23, 2024
10 checks passed
@jsolaas jsolaas deleted the refactor/time_series_collection branch September 23, 2024 10:16
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