Skip to content

send file as input for glide transformer. #271

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions apps/etl/transform/sources/glide.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import json

from pystac_monty.sources.common import DataType, File
from pystac_monty.sources.glide import GlideDataSource, GlideTransformer

from apps.etl.models import ExtractionData
from apps.etl.transform.sources.handler import BaseTransformerHandler
from apps.etl.utils import write_into_temp_file
from main.celery import app


Expand All @@ -13,10 +15,12 @@ class GlideTransformHandler(BaseTransformerHandler[GlideTransformer, GlideDataSo

@classmethod
def get_schema_data(cls, extraction_obj):
with extraction_obj.resp_data.open() as file_data:
data = file_data.read()
with extraction_obj.resp_data.open("rb") as f:
data = f.read()
data_file = write_into_temp_file(data)
data_source = {"source_url": extraction_obj.url, "source_data": File(path=data_file.name, data_type=DataType.FILE)}

return cls.transformer_schema(source_url=extraction_obj.url, data=data)
return cls.transformer_schema(data_source)

@staticmethod
@app.task
Expand Down
2 changes: 1 addition & 1 deletion libs/pystac-monty
Loading