Open-EO / openeo-python-driver

Common parts of a Python driver implementation for OpenEO
Apache License 2.0
11 stars 5 forks source link

Encapsulate "driver implementation" functions #8

Closed soxofaan closed 4 years ago

soxofaan commented 5 years ago

openeo-python-driver allows a plugable "DRIVER_IMPLEMENTATION_PACKAGE", but does this quite rudimentary at the moment. E.g:

i = importlib.import_module(os.getenv('DRIVER_IMPLEMENTATION_PACKAGE', "dummy_impl"))
getImageCollection = i.getImageCollection
get_layers = i.get_layers
try:
    create_process_visitor = i.create_process_visitor
except AttributeError as e:
    create_process_visitor = None
create_batch_job = i.create_batch_job
run_batch_job = i.run_batch_job
get_batch_job_info = i.get_batch_job_info
get_batch_job_result_filenames = i.get_batch_job_result_filenames

( https://github.com/Open-EO/openeo-python-driver/blob/314023137/openeo_driver/ProcessGraphDeserializer.py#L67 )

This approach of copy-pasting toplevel functions scales quite ugly and ruins code intelligence in your editor/IDE.

It would be cleaner to encapsulate this intermediate "API" e.g. as (abstract) classes that backends have to implement. This is more explicit API-wise, more self documenting and allows your IDE to be more helpful.

soxofaan commented 4 years ago

done (as part of #34)