-
Notifications
You must be signed in to change notification settings - Fork 4
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
Update notebooks #203
Merged
Merged
Update notebooks #203
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4c50022
update explanation CDSE
jdegerickx 6350015
add information on job_results
jdegerickx 5b0d4f8
update croptype notebooks with new querying public extractions flow
jdegerickx 88e2616
save openeo results to pickle
jdegerickx 2e6bb8d
update date slider
jdegerickx 435f4d2
final update date slider
jdegerickx 71c909a
include buffer for crop type querying
jdegerickx 6a17c87
delete redundant notebook
jdegerickx d4fae40
don't store results in run-specific folder
jdegerickx 4300259
remove save results to pickle
jdegerickx 6533f4d
explicitly add buffer to query
jdegerickx 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 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import ast | ||
import copy | ||
import logging | ||
import pickle | ||
import random | ||
from calendar import monthrange | ||
from datetime import datetime, timedelta | ||
|
@@ -849,6 +850,39 @@ def prepare_visualization(results): | |
return final_paths | ||
|
||
|
||
def _results_to_pickle(results, output_dir): | ||
"""Save the results of an openeo inference run to a pickle file. | ||
|
||
Parameters | ||
---------- | ||
results : WorldCereal InferenceResults object | ||
Results object containing the results to save. | ||
output_dir : Path | ||
Directory where the results will be saved. | ||
""" | ||
output_dir.mkdir(parents=True, exist_ok=True) | ||
with open(output_dir / "results.pkl", "wb") as f: | ||
pickle.dump(results, f) | ||
|
||
|
||
def _results_from_pickle(output_dir): | ||
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.
|
||
"""Load the results from a pickle file. | ||
|
||
Parameters | ||
---------- | ||
output_dir : Path | ||
Path to the output directory containing the results. | ||
|
||
Returns | ||
------- | ||
WorldCereal InferenceResults | ||
Results object containing the loaded results from an openeo inference run. | ||
""" | ||
with open(output_dir / "results.pkl", "rb") as f: | ||
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. build in resilience if file is not there? Would start from pure file path, not a directory. |
||
results = pickle.load(f) | ||
return results | ||
|
||
|
||
############# PRODUCT VISUALIZATION ############# | ||
|
||
|
||
|
This file contains 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 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 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.
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.
This should not be a private method, and probably be called differently, like
save_job_results
. Can you also add the required type hinting for arguments and return of the method (-> None
)?I also don't get why you specify an output_dir that then also still needs to be created. Why not the path to the exact file constructed the same way as the job result name? Wouldn't silently make directories here.