Summary
At the moment, each converter takes a number of boilerplate parameters to do with authentication and upload that aren't necessarily needed to perform a conversion. I propose that instead of this, the converters only take the parameters needed to convert to the intermediary objects and/or the final schema objects, and the uploading to Evo can be a separate process with its own parameters.
Background
Right now the converters look like:
def convert_yourfiletype(
filepath: str,
epsg_code: int,
evo_workspace_metadata: Optional[EvoWorkspaceMetadata] = None,
service_manager_widget: Optional["ServiceManagerWidget"] = None,
upload_path: str = "",
) -> list[ObjectMetadata]:
In some cases (but not all), setting upload_path to None will cause the geoscience objects to be returned instead of uploading them. If this is the case, the evo_workspace_metadata/service_manager_widget are not required, and the return format of the function changes. This makes static analysis for type checking more complex.
A consistent return format that is a wrapper for the conversion result would allow for a consistent upload interface, and make features like versioning only happen in one place.
This might look like:
def convert_yourfiletype(
filepath: str,
epsg_code: int
) -> ConversionResult:
class ConversionResult:
geoscience_objects: ObjectCollector
...
def upload(self, upload_path: str, overwrite: bool = False) -> list[ObjectMetadata]:
...
Also, I think the authentication/configuration piece could be handled with a context manager:
with EvoContext(evo_workspace_metadata=meta):
convert_yourfiletype(filepath="/path/to/my.file")
.upload("my-upload/path")
This would allow for other optional configuration around the interface to Evo to be kept in context, rather than passed through all the converters. Currently, much of this kind of context is already wrapped in EvoWorkspaceMetadata/ServiceManagerWidget, but there could be additional context in future.
User Story
As a user of this library
I want to have a consistent, lean, chainable API for converting different file types
So that my code is cleaner and easier to read
Acceptance Criteria
- All converter functions have the same parameters that work the same way
- Uploading is an optional step for all converters
- Easy to test the converter functions without any Evo context
- Tests updated to work
- Readme updated with new expectations
Out of Scope
- Implementing overwrite/revisioning as part of this, as this is happening elsewhere
- Changing the way files are loaded for conversion, as the underlying converter libraries typically want to handle this themselves
References
N/A
Implementation Notes
Definition of Done
Summary
At the moment, each converter takes a number of boilerplate parameters to do with authentication and upload that aren't necessarily needed to perform a conversion. I propose that instead of this, the converters only take the parameters needed to convert to the intermediary objects and/or the final schema objects, and the uploading to Evo can be a separate process with its own parameters.
Background
Right now the converters look like:
In some cases (but not all), setting
upload_pathtoNonewill cause the geoscience objects to be returned instead of uploading them. If this is the case, theevo_workspace_metadata/service_manager_widgetare not required, and the return format of the function changes. This makes static analysis for type checking more complex.A consistent return format that is a wrapper for the conversion result would allow for a consistent upload interface, and make features like versioning only happen in one place.
This might look like:
Also, I think the authentication/configuration piece could be handled with a context manager:
This would allow for other optional configuration around the interface to Evo to be kept in context, rather than passed through all the converters. Currently, much of this kind of context is already wrapped in
EvoWorkspaceMetadata/ServiceManagerWidget, but there could be additional context in future.User Story
As a user of this library
I want to have a consistent, lean, chainable API for converting different file types
So that my code is cleaner and easier to read
Acceptance Criteria
Out of Scope
References
N/A
Implementation Notes
Definition of Done