Skip to content
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

BAI-940 Create Helper Classes #891

Merged
merged 36 commits into from
Nov 27, 2023
Merged

BAI-940 Create Helper Classes #891

merged 36 commits into from
Nov 27, 2023

Conversation

bw27492
Copy link
Member

@bw27492 bw27492 commented Nov 18, 2023

No description provided.

@bw27492 bw27492 marked this pull request as draft November 18, 2023 18:10
res = requests.request(method, **kwargs)

# Check response for a valid range
if 200 <= res.status_code < 300:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be replaced with res.status_code < 400.

return res

# Give the error message issued by bailo
raise BailoException(res.json()['error']['message'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't exist if it's a network error, as opposed to an error from Bailo. E.g. if the connection is refused.

"""
with self.agent.get(f"{self.url}/v2/model/{model_id}/file/{file_id}/download", stream=True) as r:
if localfile_name is None:
fp = tempfile.NamedTemporaryFile()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our core client should probably not be saving things to file on disk. This should be moved out to the helper. A core client use case might be saving to S3 / another drive with more space.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I'm just going to use ByteStreams that can be used within a context manager. This will also make them file compatible as well eg. if a user want's to download files

with open("example.txt", "wb") as f:
    release.download(<file-id>, f)

return self.agent.post(
f"{self.url}/v2/model/{model_id}/files/upload/simple",
params={"name":name},
files={name: f}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

files uses a multi-form file upload. This will return a 200, but I think the uploaded data will differ from the values you provide...? So you'll upload a file saying 'Hello', then get back a file like:

-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="name"

Hello

You'll instead want to use data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, again, the core client shouldn't be reading from disk. See people uploading from Weights & Biases, S3, etc.

Model = 'model'
Release = 'release'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no Release schema. The release fields are not configurable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe review this reviews.py.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this anymore!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting file. I don't think we need this.

# Check they're the same access request
assert ar == get_ar

ar.delete()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to check that this works?

@@ -96,10 +97,10 @@ def test_post_release(requests_mock):
client = Client("https://example.com")
result = client.post_release(
model_id="test_id",
model_card_version=1,
model_card_version=1.0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be a float!

@bw27492 bw27492 marked this pull request as ready for review November 27, 2023 15:05
@bw27492 bw27492 merged commit 1d22d60 into main Nov 27, 2023
@bw27492 bw27492 deleted the BAI-940/create-helper-classes branch November 27, 2023 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants