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

Move models actions to v2 protocol #35

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Move models actions to v2 protocol #35

wants to merge 13 commits into from

Conversation

NRHelmi
Copy link
Contributor

@NRHelmi NRHelmi commented Sep 20, 2022

Use v2 protocol for model actions

rai/client.go Outdated
tx := NewTransaction(c.Region, database, engine, "OPEN")
data := tx.Payload(makeListModelsAction())
err := c.Post(PathTransaction, tx.QueryArgs(), data, &result)
models, err := c.ListModels(database, engine)
Copy link

Choose a reason for hiding this comment

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

Why would we query out all models just to return a single one? We should issue a separate query here targeting a single model. This is no different than if a database has 1,000,000 products in it. You wouldn't query out all 1,000,000 just to return a single one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's right 😬 will fix this

Copy link
Collaborator

Choose a reason for hiding this comment

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

this was done previously as it was the only way to retrieve a single model, with the expectation that we would eventually replace with an appropriate API call.

rai/client.go Outdated
tx := NewTransaction(c.Region, database, engine, "OPEN")
data := tx.Payload(makeListModelsAction())
err := c.Post(PathTransaction, tx.QueryArgs(), data, &models)
modelNames := make([]string, 0)
Copy link

Choose a reason for hiding this comment

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

Similar issue here. We shouldn't query out the models and all their source code just to return the names. We can write a query to only return the names.

rai/client.go Outdated
result = append(result, model.Name)

for _, res := range resp.Results {
if strings.Contains(res.RelationID, "/:output/:__models__") {
Copy link

@larf311 larf311 Sep 20, 2022

Choose a reason for hiding this comment

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

Why are we using weird relation names like __models__?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will update this to /:output/:models

@NRHelmi NRHelmi requested a review from torkins October 5, 2022 19:10
rai/client.go Outdated
tx := NewTransaction(c.Region, database, engine, "OPEN")
data := tx.Payload(makeListModelsAction())
err := c.Post(PathTransaction, tx.QueryArgs(), data, &result)
models, err := c.ListModels(database, engine)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this was done previously as it was the only way to retrieve a single model, with the expectation that we would eventually replace with an appropriate API call.

rai/client.go Outdated
data := tx.Payload(makeListModelsAction())
err := c.Post(PathTransaction, tx.QueryArgs(), data, &models)
models := make([]Model, 0)
resp, err := c.Execute(database, engine, "def output:__models__ = rel:catalog:model", nil, true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

again, why are we qualifying the output relation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh this is an old commit, we no longer query for all models (including name and source)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we qualify output relation to prevent accidental collisions between output results

@NRHelmi NRHelmi requested a review from bradlo October 12, 2022 23:07
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.

None yet

3 participants