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

Feature extractors #38

Merged
merged 22 commits into from
Feb 5, 2024
Merged

Feature extractors #38

merged 22 commits into from
Feb 5, 2024

Conversation

GriffinBabe
Copy link
Collaborator

Created feature extractors for users. A class must be created by extending the PatchFeatureExtractor class and implementing two methods: execute and get_labels. The execute method contains the logic applied in the UDF, while the method get_labels specifies the names of the feature bands to be applied after the UDF in the openeo job.

@GriffinBabe GriffinBabe added the enhancement New feature or request label Feb 1, 2024
…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
Copy link
Member

@soxofaan soxofaan left a 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

src/openeo_gfmap/features/feature_extractor.py Outdated Show resolved Hide resolved
Copy link
Member

@soxofaan soxofaan left a 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

cases/IFAD_Sudan/quantile_feature_extractor.py Outdated Show resolved Hide resolved
cases/world_cereal/presto_feature_extractor.py Outdated Show resolved Hide resolved

REQUIRED_IMPORTS = """
import inspect
from abc import ABC, abstractmethod
Copy link
Member

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?

Copy link
Collaborator Author

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

Copy link
Member

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

Copy link
Member

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, ...)

src/openeo_gfmap/features/feature_extractor.py Outdated Show resolved Hide resolved
src/openeo_gfmap/features/feature_extractor.py Outdated Show resolved Hide resolved
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"
Copy link
Member

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

src/openeo_gfmap/inference/inference_models.py Outdated Show resolved Hide resolved
tests/test_openeo_gfmap/test_feature_extractors.py Outdated Show resolved Hide resolved
@soxofaan
Copy link
Member

soxofaan commented Feb 2, 2024

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

@GriffinBabe GriffinBabe merged commit 960d9c0 into main Feb 5, 2024
2 checks passed
@GriffinBabe GriffinBabe deleted the feature_extractors branch February 5, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants