Skip to content

Conversation

@anthonykrivonos
Copy link
Contributor

@anthonykrivonos anthonykrivonos commented Nov 23, 2022

Added support for uploading metrics at the track level from the SDK.

Tested everything in https://github.com/scaleapi/scaleapi/pull/50768. Will merge after the scaleapi changes are deployed and tests pass.


self.tqdm_bar = tqdm_notebook.tqdm
self._connection = Connection(self.api_key, self.endpoint)
self.connection = Connection(self.api_key, self.endpoint)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tricky design decision here. Track needs access to at least a Connection object to be able to call the API to upload track metadata, preferably NucleusClient access for consistency with other classes like Model. However, a Validate instance is created from NucleusClient, and so attempting to import Track from ScenarioTest, from where it is created in get_items, will cause a circular import. The lessermost evil was to update Track.from_json to take a Connection instead of a NucleusClient.

The tradeoff here was exposing connection as a public property of NucleusClient so to access this property when creating Tracks in cases when only a NucleusClient is available. This should be safe, since a Connection consists of two public properties––api_key and endpoint.

Lmk if there are any issues with this approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this is fine.

I think passing around a connection is a newer approach than passing the client. I actually don't see any reason for a class having to have full access to the client. We should probably refactor everything to pass around the connection object itself.

I don't see any harm in doing things this way so ... let's go ahead 🙂

)
if level == EntityLevel.TRACK:
return [
Track.from_json(track, connection=self.connection)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line is the reason for the long justification above 😤

Copy link
Contributor

Choose a reason for hiding this comment

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

Haha, the struggle is real 🥇

test_slice,
slice_items,
):
# Arrange
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored the test_scenario_test_get_* methods via AAA-C bc of my OCD

Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to drop the link next to one of the comments 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's ok, pretty common paradigm and future tests can use the structure of these functions as inspiration. Don't feel too fond about linking to Medium lmao

@anthonykrivonos anthonykrivonos marked this pull request as ready for review November 29, 2022 18:46
Copy link
Contributor

@gatli gatli left a comment

Choose a reason for hiding this comment

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

LGTM 👍


self.tqdm_bar = tqdm_notebook.tqdm
self._connection = Connection(self.api_key, self.endpoint)
self.connection = Connection(self.api_key, self.endpoint)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this is fine.

I think passing around a connection is a newer approach than passing the client. I actually don't see any reason for a class having to have full access to the client. We should probably refactor everything to pass around the connection object itself.

I don't see any harm in doing things this way so ... let's go ahead 🙂

)
if level == EntityLevel.TRACK:
return [
Track.from_json(track, connection=self.connection)
Copy link
Contributor

Choose a reason for hiding this comment

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

Haha, the struggle is real 🥇

test_slice,
slice_items,
):
# Arrange
Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to drop the link next to one of the comments 👍

@anthonykrivonos anthonykrivonos merged commit 2028e55 into master Dec 1, 2022
@anthonykrivonos anthonykrivonos deleted the kriv-val-track-metrics branch December 1, 2022 18:36
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