-
Notifications
You must be signed in to change notification settings - Fork 6
Handling no received data from WeatherSource #1145
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
Open
PhilippSchmelter
wants to merge
76
commits into
dev
Choose a base branch
from
ps/#554-HandlingNoWeatherData
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 40 commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
529bf23
Testing method
PhilippSchmelter f72bb75
Fixed format
PhilippSchmelter 9447e8b
Fixed format
PhilippSchmelter e0828af
Fixed Test
PhilippSchmelter 6c4c0f8
Revert "Testing method"
PhilippSchmelter 7502d97
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 743e99a
Testing NoWeatherDataException
PhilippSchmelter 74f4816
Handled NoWeatherData in for CSV Source
PhilippSchmelter 8e8bed0
Handled NoWeatherData in for CSV Source
PhilippSchmelter 21a05a3
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter e0bcfb6
Adapted exception throwing for getWeather() which returns optional an…
PhilippSchmelter cee6660
Started adding NoDataException for SQL source
PhilippSchmelter 8ed3f29
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter f7a21d4
Spotless Applied
PhilippSchmelter 646eaa8
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter e666ea0
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 171610b
Removed all occurences of Optional return type for getWeather() methods
PhilippSchmelter 08a2679
spotless
PhilippSchmelter 2a4d3b7
fixed tests
PhilippSchmelter 7d449ee
Adapted SourceIconIT tests
PhilippSchmelter c83ca93
Fixed tests
PhilippSchmelter 34d78aa
Fixed tests
PhilippSchmelter 19d5c3b
Spotless Apply
PhilippSchmelter ad8946f
Final
PhilippSchmelter e1ec1db
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 703e581
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter cd5354d
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 6723cba
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 23b732f
Resolved Conversations
PhilippSchmelter 88e1ec7
Fixed Tests
PhilippSchmelter cc9e1a0
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 60ef7f5
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 57ca9ab
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 69838ed
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter a8f892d
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 01146b9
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 955239e
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter faa36cf
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 22ca7f6
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
danielfeismann 24441c9
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
danielfeismann 8c2d1f7
Resolved Conversations
PhilippSchmelter 9915bee
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter 5dc0f4a
spotless
PhilippSchmelter b9d747f
Merge remote-tracking branch 'origin/ps/#554-HandlingNoWeatherData' i…
PhilippSchmelter 68ea181
improvements
PhilippSchmelter c2117e2
spotless
PhilippSchmelter b8ff373
fixed tests
PhilippSchmelter 35a497d
spotless
PhilippSchmelter 3951355
tests
PhilippSchmelter 24ff4b5
added exception to couchbase tests
PhilippSchmelter e8a4fee
some fixes
PhilippSchmelter 5cc104b
some fixes
PhilippSchmelter 9f97b00
no more missing data
PhilippSchmelter 4be6590
edited exception
PhilippSchmelter f20db54
bugfix
PhilippSchmelter fd0823b
fx
PhilippSchmelter ef08123
redundant log removed
PhilippSchmelter cf8adb3
hopefully final
PhilippSchmelter 701d7e2
spotless
PhilippSchmelter b5d2ccf
more information
PhilippSchmelter dfb49df
fix
PhilippSchmelter c75b9fa
aa
PhilippSchmelter dc35434
Revert "redundant log removed"
PhilippSchmelter 24e8d3f
Merge remote-tracking branch 'origin/ps/#554-HandlingNoWeatherData' i…
PhilippSchmelter 0800310
Revert "fx"
PhilippSchmelter a2911b0
sql
PhilippSchmelter ce294c5
couchbaase
PhilippSchmelter c38e7a5
hopefully final
PhilippSchmelter 3ebda49
bug
PhilippSchmelter bdd0ae8
Strict fail-fast on partial results
PhilippSchmelter 7f6a59c
Revert "Strict fail-fast on partial results"
PhilippSchmelter 183e0c8
little improvement
PhilippSchmelter bf86b78
removed unnecessary info from exception
PhilippSchmelter 67000bd
spotless...
PhilippSchmelter 1be0b8e
removed unnecessary test
PhilippSchmelter 4b81cd1
Merge branch 'dev' into ps/#554-HandlingNoWeatherData
PhilippSchmelter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/edu/ie3/datamodel/exceptions/NoDataException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* © 2024. TU Dortmund University, | ||
* Institute of Energy Systems, Energy Efficiency and Energy Economics, | ||
* Research group Distribution grid planning and operation | ||
*/ | ||
package edu.ie3.datamodel.exceptions; | ||
|
||
/** | ||
* Exception that should be used whenever no data is received{@link | ||
* edu.ie3.datamodel.io.source.DataSource} | ||
* | ||
* @version 0.1 | ||
* @since 04.09.24 | ||
PhilippSchmelter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
public class NoDataException extends Exception { | ||
|
||
public NoDataException(final String message) { | ||
super(message); | ||
} | ||
} | ||
PhilippSchmelter marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
import com.couchbase.client.java.json.JsonObject; | ||
import com.couchbase.client.java.kv.GetResult; | ||
import com.couchbase.client.java.query.QueryResult; | ||
import edu.ie3.datamodel.exceptions.NoDataException; | ||
import edu.ie3.datamodel.io.connectors.CouchbaseConnector; | ||
import edu.ie3.datamodel.io.factory.timeseries.TimeBasedWeatherValueData; | ||
import edu.ie3.datamodel.io.factory.timeseries.TimeBasedWeatherValueFactory; | ||
|
@@ -105,7 +106,7 @@ public Optional<Set<String>> getSourceFields() { | |
|
||
@Override | ||
public Map<Point, IndividualTimeSeries<WeatherValue>> getWeather( | ||
ClosedInterval<ZonedDateTime> timeInterval) { | ||
ClosedInterval<ZonedDateTime> timeInterval) throws NoDataException { | ||
logger.warn( | ||
"By not providing coordinates you are forcing couchbase to check all possible coordinates one by one." | ||
+ " This is not very performant. Please consider providing specific coordinates instead."); | ||
|
@@ -114,7 +115,8 @@ public Map<Point, IndividualTimeSeries<WeatherValue>> getWeather( | |
|
||
@Override | ||
public Map<Point, IndividualTimeSeries<WeatherValue>> getWeather( | ||
ClosedInterval<ZonedDateTime> timeInterval, Collection<Point> coordinates) { | ||
ClosedInterval<ZonedDateTime> timeInterval, Collection<Point> coordinates) | ||
throws NoDataException { | ||
HashMap<Point, IndividualTimeSeries<WeatherValue>> coordinateToTimeSeries = new HashMap<>(); | ||
for (Point coordinate : coordinates) { | ||
Optional<Integer> coordinateId = idCoordinateSource.getId(coordinate); | ||
|
@@ -138,32 +140,41 @@ public Map<Point, IndividualTimeSeries<WeatherValue>> getWeather( | |
new IndividualTimeSeries<>(weatherInputs); | ||
coordinateToTimeSeries.put(coordinate, weatherTimeSeries); | ||
} | ||
} else logger.warn("Unable to match coordinate {} to a coordinate ID", coordinate); | ||
} else { | ||
logger.error("Unable to match coordinate {} to a coordinate ID", coordinate); | ||
throw new NoDataException("No data found"); | ||
PhilippSchmelter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
return coordinateToTimeSeries; | ||
} | ||
|
||
@Override | ||
public Optional<TimeBasedValue<WeatherValue>> getWeather(ZonedDateTime date, Point coordinate) { | ||
public TimeBasedValue<WeatherValue> getWeather(ZonedDateTime date, Point coordinate) | ||
throws NoDataException { | ||
Optional<Integer> coordinateId = idCoordinateSource.getId(coordinate); | ||
if (coordinateId.isEmpty()) { | ||
logger.warn("Unable to match coordinate {} to a coordinate ID", coordinate); | ||
return Optional.empty(); | ||
logger.error("Unable to match coordinate {} to a coordinate ID", coordinate); | ||
throw new NoDataException("No coordinate ID found for the given point."); | ||
PhilippSchmelter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
try { | ||
CompletableFuture<GetResult> futureResult = | ||
connector.get(generateWeatherKey(date, coordinateId.get())); | ||
GetResult getResult = futureResult.join(); | ||
JsonObject jsonWeatherInput = getResult.contentAsObject(); | ||
return toTimeBasedWeatherValue(jsonWeatherInput); | ||
return toTimeBasedWeatherValue(jsonWeatherInput) | ||
.orElseThrow( | ||
() -> | ||
new NoDataException( | ||
"No valid weather data found for the given date and coordinate.")); | ||
Comment on lines
+175
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here: Maybe try to take an earlier data point instead? |
||
} catch (DecodingFailureException ex) { | ||
logger.error("Decoding to TimeBasedWeatherValue failed!", ex); | ||
return Optional.empty(); | ||
throw new NoDataException("Failed to decode weather data."); | ||
PhilippSchmelter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} catch (DocumentNotFoundException ex) { | ||
return Optional.empty(); | ||
throw new NoDataException("Weather document not found."); | ||
} catch (CompletionException ex) { | ||
if (ex.getCause() instanceof DocumentNotFoundException) return Optional.empty(); | ||
else throw ex; | ||
if (ex.getCause() instanceof DocumentNotFoundException) { | ||
throw new NoDataException("Weather document not found in the completion stage."); | ||
} else throw ex; | ||
} | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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