-
Notifications
You must be signed in to change notification settings - Fork 2
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
File outputs #54
File outputs #54
Conversation
ThingClient subclasses can now be initialised from URLs. thing_client_from_url is now ThingClient.from_url
NB these are both untested and unused.
Actions may now declare a return type derived from BlobOutput. This will serialise to a JSON link specifying the media type, and will allow us to return a raw (can be binary) response. In the future, we should use the `accept` HTTP header to pick whether to return JSON or the specified mime type. We should also implement behaviour that makes the 200 status code reachable from an action invocation.
The HTTP client now checks whether the output of an action is a blob. If so, it will return a ClientBlobOutput that downloads it and either saves to a file or returns as bytes.
This should do a complete test of blob output - using both the temp dir based and bytes-based methods of constructing it, and retrieving it via the three specified methods.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #54 +/- ##
==========================================
+ Coverage 75.25% 78.70% +3.44%
==========================================
Files 26 28 +2
Lines 1475 1620 +145
==========================================
+ Hits 1110 1275 +165
+ Misses 365 345 -20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Test coverage of the diff isn't 100%, but most of the missed lines are ones I don't expect we'll need often or at all. Improving coverage is always a good idea, but I'm going to prioritise other things for now. File outputs work, and are tested - we will need to add the ability to handle particular media types more nicely (e.g. convert JPEG images into PIL objects or arrays), but the basics seem good for now. |
I've added a BlobOutput class that makes file outputs from actions much neater. For now, actions may declare their return type as a subclass of
BlobOutput
, having set themedia_type
property. The function must then return a BlobOutput instance, which will appear as a link in theoutput
member of an action invocation.The link will point to
/invocations/{id}/output/
and, when followed, will return the output directly.Future extensions might include: