[Do not merge] Testing inference - #107
Conversation
yixu34
left a comment
There was a problem hiding this comment.
Think it's a bit too early to say more, but looks like the skeleton is coming together 💀
| dataclasses = { version = "^0.7", python = "^3.6.1, <3.7" } | ||
| aiohttp = "^3.7.4" | ||
| nest-asyncio = "^1.5.1" | ||
| dill = "^0.3.0" |
There was a problem hiding this comment.
Btw my latest script used cloudpickle.
| mypy = "^0.812" | ||
| coverage = "^5.5" | ||
| pre-commit = "^2.12.1" | ||
| torch = "1.7.1" # Test uploading model bundles only |
There was a problem hiding this comment.
Not sure if this too was temporary, but this brings up an interesting question around whether or not we want to package a certain version of pytorch in here. Seems like we should use whatever the user has installed locally.
There was a problem hiding this comment.
Oh the reason this is in here is that I wanted to test uploading model bundles, so I used some stuff from pytorch. This is only a dependency of one test case, and is under [requirements-test]. I definitely think it would be weird/bad if nucleus-python-client (the package) had torch = 1.7.1 as a dependency.
yixu34
left a comment
There was a problem hiding this comment.
Will do another pass tomorrow.
| @@ -0,0 +1,36 @@ | |||
| n.b. doesn't look like this readme gets copied into the sphinx docs | |||
|
|
||
| # Scale Deploy | ||
|
|
||
| Shamelessly copied from PRFAQ :) |
There was a problem hiding this comment.
There is no shame in copy and paste 🌚
| """ | ||
| # Scale Deploy | ||
|
|
||
| Shamelessly copied from PRFAQ :) |
| self, api_key: str, endpoint: str = HOSTED_INFERENCE_ENDPOINT | ||
| ): | ||
| """ | ||
| Initializes a HostedInference Client. |
There was a problem hiding this comment.
I think we actually want to rename all this public, user-facing stuff from hosted model inference -> deploy.
| # Try to upload resulting predictions to nucleus | ||
|
|
||
| def _infer( | ||
| def infer( |
There was a problem hiding this comment.
I'd say predict is a more common name that appears in these kinds of frameworks.
|
|
||
| Parameters: | ||
| endpoint_id: The id of the endpoint to make the request to | ||
| s3url: A url that points to a file containing model input. |
There was a problem hiding this comment.
For synchronous requests, I think we want to support inline payloads as well, i.e. you just send an image payload directly. This does get tricky with large payloads, though, where we'd probably want to stream the data in.
Anyway, I guess the point is that for synchronous endpoints:
- We might not know the specifics yet for inline payloads, but:
- We're pretty sure we will want them, which means that S3 URLs are not the only way, and should thus be
Optional.
Another observation re: s3 urls is that we probably want to abstract this into a generic URI. This is because HMI can be self-hosted, in which case we'd want to support other schemes. Nucleus is able to assume S3 URLs because it's Scale-hosted.
| resp = self.connection.get(route=f"task/result/{async_task_id}") | ||
| return resp["data"] | ||
|
|
||
| def batch_request(self, endpoint_id, s3urls: List[str]): |
There was a problem hiding this comment.
I made a comment on @Tianwei-She 's PR here: https://github.com/scaleapi/models/pull/2315#discussion_r784440984 - wondering if we can just get rid of this method.
| A higher level abstraction for a Model Endpoint. | ||
| """ | ||
|
|
||
| def __init__(self, endpoint_id, client): |
There was a problem hiding this comment.
These could use some type annotations and docstring.
| @@ -0,0 +1,161 @@ | |||
| # This file contains all the Core Nucleus <-> HMI integrations | |||
There was a problem hiding this comment.
A couple of thoughts:
- Maybe we should just rename this folder to
deploy. This is just going to go into a separate release branch in the meantime anyway. - Regardless of what we name this folder (where the HMI/deploy stuff lives), I'd say that the integration code should go in an actual Nucleus folder. This way, it's clear that Nucleus depends on Deploy, without an inverse dependency too. Having this integration file here means that we can't just move this folder to a separate repo later, for instance.
| hmi_client = HostedInference( | ||
| api_key="live_38aa469bc8ab436d89dce6e37e8d5258" | ||
| ) | ||
| img_url = "s3://scale-ml-hosted-model-inference/tmp/hosted-model-inference-outputs/c3f3b5ed-f182-4fa1-bfa5-9b2e017feb74.pkl" |
There was a problem hiding this comment.
Probably best to remove any internal URLs in here. It's not the end of the world since's temporary and not a secret.
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def edit_endpoint(self): |
92aa45b to
2168bc4
Compare
|
See #203 |

Companion: https://github.com/scaleapi/models/pull/1847
Superseded by #203