Skip to content

Commit

Permalink
FIX: Fixing handler and TerrainTiles/Modis so that AWS API Gateway La…
Browse files Browse the repository at this point in the history
…mbda functions work out-of-the-box with the dev version of PODPAC.
  • Loading branch information
mpu-creare committed Jun 11, 2020
1 parent 0819288 commit 7f5faf2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
12 changes: 8 additions & 4 deletions dist/aws/handler.py
Expand Up @@ -222,14 +222,17 @@ def handler(event, context):
bucket = os.environ.get("S3_BUCKET_NAME", pipeline["settings"].get("S3_BUCKET_NAME"))

# get dependencies path
if "FUNCTION_DEPENDENCIES_KEY" in pipeline["settings"]:
if "FUNCTION_DEPENDENCIES_KEY" in pipeline["settings"] or "FUNCTION_DEPENDENCIES_KEY" in os.environ:
dependencies = os.environ.get(
"FUNCTION_DEPENDENCIES_KEY", pipeline["settings"].get("FUNCTION_DEPENDENCIES_KEY")
)
else:
dependencies = "podpac_deps_{}.zip".format(
os.environ.get("PODPAC_VERSION", pipeline["settings"].get("PODPAC_VERSION"))
) # this should be equivalent to version.semver()
)
if 'None' in dependencies:
dependencies = 'podpac_deps.zip' # Development version of podpac
# this should be equivalent to version.semver()

# Check to see if this function is "hot", in which case the dependencies have already been downloaded and are
# available for use right away.
Expand All @@ -240,7 +243,7 @@ def handler(event, context):
)
else:
# Download dependencies from specific bucket/object
print ("Downloading and extracting dependencies")
print ("Downloading and extracting dependencies from {} {}".format(bucket, dependencies))
s3 = boto3.client("s3")
s3.download_file(bucket, dependencies, "/tmp/" + dependencies)
subprocess.call(["unzip", "/tmp/" + dependencies, "-d", "/tmp"])
Expand All @@ -261,8 +264,9 @@ def handler(event, context):
import podpac.datalib

# update podpac settings with inputs from the trigger
settings.update(json.loads(os.environ.get("SETTINGS", "{}")))
settings.update(pipeline["settings"])

# build the Node and Coordinates
if trigger in ("eval", "S3"):
node = Node.from_definition(pipeline["pipeline"])
Expand Down
5 changes: 3 additions & 2 deletions podpac/datalib/modis_pds.py
Expand Up @@ -124,7 +124,7 @@ class MODISSource(Rasterio):
vertical = tl.Unicode(help="row in the MODIS Sinusoidal Tiling System, e.g. '07'").tag(attr=True)
date = tl.Unicode(help="year and three-digit day of year, e.g. '2011460'").tag(attr=True)
data_key = tl.Unicode(help="data to retrieve (varies by product)").tag(attr=True)

anon = tl.Bool(True)
check_exists = tl.Bool(True)

_repr_keys = ["prefix", "data_key"]
Expand Down Expand Up @@ -181,7 +181,7 @@ class MODISTile(S3Mixin, DataSource):
horizontal = tl.Unicode(help="column in the MODIS Sinusoidal Tiling System, e.g. '21'").tag(attr=True)
vertical = tl.Unicode(help="row in the MODIS Sinusoidal Tiling System, e.g. '07'").tag(attr=True)
data_key = tl.Unicode(help="data to retrieve (varies by product)").tag(attr=True)

anon = tl.Bool(True)
_repr_keys = ["product", "data_key"]

@cached_property
Expand Down Expand Up @@ -243,6 +243,7 @@ class MODIS(S3Mixin, OrderedCompositor):
tile_width = (1, 2400, 2400)
start_date = "2013-01-01"
end_date = datetime.date.today().strftime("%Y-%m-%d")
anon = tl.Bool(True)

_repr_keys = ["product", "data_key"]

Expand Down
2 changes: 1 addition & 1 deletion podpac/datalib/terraintiles.py
Expand Up @@ -67,7 +67,7 @@ class TerrainTilesSource(Rasterio):
dataset : :class:`rasterio.io.DatasetReader`
rasterio dataset
"""

anon = tl.Bool(True)
# attributes
interpolation = InterpolationTrait(
default_value={"method": "nearest", "interpolators": [RasterioInterpolator, ScipyGrid, ScipyPoint]}
Expand Down

0 comments on commit 7f5faf2

Please sign in to comment.