-
Notifications
You must be signed in to change notification settings - Fork 43
Add app template supported AWS lambda s3 event-based predictions #164
Conversation
Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good. Left 2 comments, nothing major.
# upload predictions to s3 | ||
out_filename = "/tmp/predictions.json" | ||
with open(out_filename, "w") as f: | ||
json.dump(predictions, f) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason not to use another NamedTemporaryFile
for the predictions as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it somehow wasn't working, the file uploaded to s3 would be empty 🤷♂️
|
||
assert ret is None | ||
mock_dl_file.assert_called_once() | ||
mock_ul_file.assert_called_once() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there anyway we could capture the content of the file being written to s3? Just to double-check we're writing the right predictions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lemme try something
Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
|
||
# Reacting to S3 Events | ||
|
||
In {ref}`serving_aws_lambda` we learned how to deploy a prediction service to an AWS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this is how you cross reference docs in markdown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually using https://myst-parser.readthedocs.io/en/latest/ for these docs... we should move Flyte (incrementally) to this, it's a lot easier to write docs for
def load_from_env(self, env_var: str = "UNIONML_MODEL_PATH", *args, **kwargs): | ||
"""Load a model object from an environment variable pointing to the model file. | ||
|
||
:env_var: environment variable referencing a path to load a model from. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing param
before env_var
.
with tempfile.NamedTemporaryFile("w") as out_file: | ||
json.dump(predictions, out_file) | ||
upload_key = f"predictions/{key.split('/')[-1]}" | ||
out_file.flush() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice.
Fixes #19
This PR creates a unionml app template that can be instantiated with
unionml init --template basic-aws-lambda-s3 APP_NAME
, which ships with the necessary SAM template, app code, handler code, and basic unit tests for users to get started with s3-event-based predictions.