Skip to content

Commit

Permalink
Cleaning up process list to dictionary convertion
Browse files Browse the repository at this point in the history
  • Loading branch information
hectormachin committed Aug 29, 2023
1 parent 2125148 commit 451c9cf
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 47 deletions.
87 changes: 45 additions & 42 deletions payload_workflow.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"id": "test",
"type": "FeatureCollection",
"features": [
{
"id": "test",
"features": [{
"id": "tx_m_2609719_se_14_060_20201217",
"bbox": [
-97.690252,
Expand All @@ -11,8 +10,7 @@
26.689923
],
"type": "Feature",
"links": [
{
"links": [{
"rel": "collection",
"type": "application/json",
"href": "https://planetarycomputer.microsoft.com/api/stac/v1/collections/naip"
Expand Down Expand Up @@ -47,24 +45,23 @@
"data"
],
"title": "RGBIR COG tile",
"eo:bands": [
{
"name": "Red",
"common_name": "red"
},
{
"name": "Green",
"common_name": "green"
},
{
"name": "Blue",
"common_name": "blue"
},
{
"name": "NIR",
"common_name": "nir",
"description": "near-infrared"
}
"eo:bands": [{
"name": "Red",
"common_name": "red"
},
{
"name": "Green",
"common_name": "green"
},
{
"name": "Blue",
"common_name": "blue"
},
{
"name": "NIR",
"common_name": "nir",
"description": "near-infrared"
}
]
},
"thumbnail": {
Expand All @@ -81,30 +78,31 @@
"coordinates": [
[
[
-97.623004,
26.622563
-97.623004,
26.622563
],
[
-97.622203,
26.689286
-97.622203,
26.689286
],
[
-97.68949,
26.689923
-97.68949,
26.689923
],
[
-97.690252,
26.623198
-97.690252,
26.623198
],
[
-97.623004,
26.622563
-97.623004,
26.622563
]
]
]
},
"collection": "naip",
"properties": {
"version": 2,
"gsd": 0.6,
"datetime": "2020-12-17T00:00:00Z",
"naip:year": "2020",
Expand Down Expand Up @@ -138,18 +136,23 @@
],
"stac_version": "1.0.0"
}],
"process": {
"process": [{
"description": "string",
"workflow": "copy-assets",
"upload_options": {
"path_template": "s3://<REPLACE_WITH_ASSETS_S3_BUCKET_NAME>/data/${collection}/${id}/",
"public_assets": [],
"s3_urls": false
"path_template": "s3://<REPLACE_WITH_ASSETS_S3_BUCKET_NAME>/data/${collection}/${id}/",
"collections": {
"naip": "*"
},
"public_assets": [],
"headers": {},
"s3_urls": false
},
"tasks": {
"copy-assets": {
"assets": ["thumbnail"],
"drop_assets": ["image"]
}
"copy-assets": {
"assets": ["thumbnail"],
"drop_assets": ["image"]
}
}
}
}]
}
7 changes: 3 additions & 4 deletions task.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ class CopyAssets(Task):

@classmethod
def validate(cls, payload: dict[str, Any]) -> bool:
payload["process"] = payload["process"][0]
payload["process"] = (
payload["process"][0] if isinstance(payload["process"], list) else payload["process"]
)
if "assets" not in payload["process"]["tasks"][cls.name]:
raise InvalidInput("assets that need to be copied required to be specified")
return True

def process(
self, assets: List[str], drop_assets: List[str]
) -> List[Dict[str, Any]]:
print(self._payload)
# process method overrides Task
created_items = []

payload = self._payload
print(payload)

try:
item = self.items[0]
Expand Down Expand Up @@ -85,7 +85,6 @@ def process(
)

def handler(event: dict[str, Any], context: dict[str, Any] = {}) -> Task:
print(event)
return CopyAssets.handler(event)


Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v0.0.6"
"version": "v0.0.7"
}

0 comments on commit 451c9cf

Please sign in to comment.