Skip to content

Conversation

PhilippSchmelter
Copy link
Contributor

Resolves #554
Added an explicit Exception for handling no received data from WeatherSource to prevent the pipeline moving on without data.

@PhilippSchmelter PhilippSchmelter self-assigned this Aug 27, 2024
@PhilippSchmelter
Copy link
Contributor Author

Handling CSV-Source done

  • all getWeather() which returned optional
    //TODO
    REST of
    SQL
    Influx
    Couchbase

@PhilippSchmelter PhilippSchmelter marked this pull request as ready for review September 30, 2024 22:37
@PhilippSchmelter
Copy link
Contributor Author

@danielfeismann
I think now this Issue should be covered :D
Feel free to check the changes and let me know if something doesnt fit!

Copy link
Member

@danielfeismann danielfeismann left a comment

Choose a reason for hiding this comment

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

Thank you for including my points. I do have another one or two points which are a bit unclear to me

@@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Enhance `TimeSeriesSource` with method to retrieve all time keys after a given key [#543](https://github.com/ie3-institute/PowerSystemDataModel/issues/543)
- Enhance `WeatherSource` with method to retrieve all time keys after a given key [#572](https://github.com/ie3-institute/PowerSystemDataModel/issues/572)
- Added explicit handling for cases where no weather data is received from any source [#554](https://github.com/ie3-institute/PowerSystemDataModel/issues/554)
Copy link
Member

Choose a reason for hiding this comment

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

Please move this to the end of this subsection

Copy link
Member

Choose a reason for hiding this comment

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

Reminder to move this to the Unreleased/Snapshot section

IndividualTimeSeries<WeatherValue> timeSeries =
new IndividualTimeSeries<>(timeBasedValues);
coordinateToTimeSeries.put(entry.getKey(), timeSeries);
if (!timeBasedValues.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

Should it also lead to an exception in case timeBasedValues is empty, since one could assume we would expect weather data when asking for it and those aren't there? Not sure about this, I might have to rethink on this.

Copy link
Member

Choose a reason for hiding this comment

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

Also, testing this would also be great.

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 tested throwing an exception when timeBasedValues is empty, but that broke existing behavior and tests. For now we keep it simple: invalid coordinates throw a NoDataException, but valid coordinates with no data just return an empty series. Or do we really want it that strict? If so we could use my last commit which I reverted again.

Copy link
Member

Choose a reason for hiding this comment

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

It'd be great to have equivalent behavior across types of data sources, at least where it's possible

Copy link
Member

@sebastian-peter sebastian-peter left a comment

Choose a reason for hiding this comment

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

While looking through this, it came to my mind that some of these errors we could try and heal instead, before throwing an exception.

I realize this requires a bit more effort, but maybe it still makes sense to handle it in this PR? On the other hand, SIMONA has to deal with these new types of exceptions anyway, and at a later step it would crash less because we healed the problem instead.

@@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Enhance `TimeSeriesSource` with method to retrieve all time keys after a given key [#543](https://github.com/ie3-institute/PowerSystemDataModel/issues/543)
- Enhance `WeatherSource` with method to retrieve all time keys after a given key [#572](https://github.com/ie3-institute/PowerSystemDataModel/issues/572)
- Added explicit handling for cases where no weather data is received from any source [#554](https://github.com/ie3-institute/PowerSystemDataModel/issues/554)
Copy link
Member

Choose a reason for hiding this comment

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

Reminder to move this to the Unreleased/Snapshot section

Comment on lines +164 to +165
logger.error("Unable to match coordinate {} to a coordinate ID", coordinate);
throw new NoDataException("No coordinate ID found for the given point: " + coordinate);
Copy link
Member

Choose a reason for hiding this comment

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

Logging an error is obsolete when we also throw and exception in the next line, imho

Comment on lines +126 to +128
if (!invalidCoordinates.isEmpty()) {
throw new NoDataException("No data for given coordinates: " + invalidCoordinates);
}
Copy link
Member

Choose a reason for hiding this comment

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

Hmm. I think there's a way to heal this instead of breaking right away.
I'd say, if for a coordinate we cannot retrieve weather data, we try to provide the last available data (the available data for the last point in time before now) first. In this case, we also log a warning.
If that also fails though, we should throw an exception.

Comment on lines +117 to +119
if (!invalidCoordinates.isEmpty()) {
throw new NoDataException("No data for given coordinates: " + invalidCoordinates);
}
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

Comment on lines +175 to +176
new NoDataException(
"No valid weather data found for the given date and coordinate."));
Copy link
Member

Choose a reason for hiding this comment

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

Same here: Maybe try to take an earlier data point instead?

Comment on lines +149 to +150
new NoDataException(
"No weather data found for the given coordinate: " + coordinate));
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

IndividualTimeSeries<WeatherValue> timeSeries =
new IndividualTimeSeries<>(timeBasedValues);
coordinateToTimeSeries.put(entry.getKey(), timeSeries);
if (!timeBasedValues.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

It'd be great to have equivalent behavior across types of data sources, at least where it's possible

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.

Explicitly handle not receiving any weather data from the weather source
3 participants