-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature extractors #38
Conversation
…o-gfmap into feature_extractors Conflicts: src/openeo_gfmap/fetching/s1.py src/openeo_gfmap/preprocessing/interpolation.py src/openeo_gfmap/preprocessing/udf_rank.py src/openeo_gfmap/preprocessing/udf_score.py src/openeo_gfmap/utils/catalogue.py src/openeo_gfmap/utils/intervals.py tests/test_openeo_gfmap/test_cloud_masking.py
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 PR is a bit too big for me to review at the moment
just a quick observation
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.
some more attempts to give this a bit of review
|
||
REQUIRED_IMPORTS = """ | ||
import inspect | ||
from abc import ABC, abstractmethod |
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.
why are inspect and abc required imports?
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.
inspect is useless in this case, I removed it, but ABC is used as it defines the base class for all feature extractors
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.
I'm actually wondering if you can't eliminate the whole REQUIRED_IMPORTS
by replacing those inspect.getsource(...)
constructs with just concatenating the python files that define these classes, then all your dependencies are handled automatically and you don't have to manually keep a REQUIRED_IMPORTS
in sync
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.
Moreover, I think it's useful to have unit tests on that UDF source code building pipeline, e.g. check that the generated UDF code can at least be parsed (e.g. to just parse with executing with ast.parse
from ast
module or full compile with compile()
built-in), and ideally also check that it can be loaded (e.g. all imports are valid, ...)
udf_code += f"{REQUIRED_IMPORTS}\n\n" | ||
udf_code += f"{inspect.getsource(FeatureExtractor)}\n\n" | ||
udf_code += f"{inspect.getsource(PatchFeatureExtractor)}\n\n" | ||
udf_code += f"{inspect.getsource(feature_extractor_class)}\n\n" |
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.
FYI: idea for future improvement: instead of manually putting the source of FeatureExtractor, PatchFeatureExtractor, feature_extractor_class here, you could also walk the inheritance trail automatically
General note: my review feedback doesn't necessarily has to block merging this PR already. This is quite a big PR and keeping it open too long is just asking for conflicts with other feature branches I'm fine with merging this as-is and fixing things up in follow-up branches/PRs |
Created feature extractors for users. A class must be created by extending the
PatchFeatureExtractor
class and implementing two methods:execute
andget_labels
. Theexecute
method contains the logic applied in the UDF, while the methodget_labels
specifies the names of the feature bands to be applied after the UDF in the openeo job.