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

Add SetTag endpoint #10

Merged
merged 27 commits into from
Oct 19, 2024
Merged

Add SetTag endpoint #10

merged 27 commits into from
Oct 19, 2024

Conversation

jescalada
Copy link
Contributor

@jescalada jescalada commented Oct 4, 2024

PR for adding the SetTag endpoint. I also added the DeleteTag endpoint from #8.

There are various new tests, all of which are passing except one:

  • PASSING: test_set_tag_with_empty_string_as_value[sqlalchemy]
  • PASSING: test_set_tag_validation[sqlalchemy]
  • PASSING: test_set_tag_truncate_too_long_tag
  • PASSING: test_update_run_name
  • PASSING: test_update_run_name_without_changing_status[sqlalchemy]
  • FAILING: test_set_tag

The reason why test_set_tag is failing, is that it uses monkeypatch to set an env, which doesn't flow to the Go side in our implementation. I have temporarily disabled that specific test by adding it to conftest.py until we can find a solution for similar tests.

I also added a test:PythonSpecific command for testing a single endpoint at a time.

Signed-off-by: Juan Escalada <[email protected]>
@jescalada
Copy link
Contributor Author

Looks like I messed up the line endings, will fix in a sec!

@jescalada jescalada marked this pull request as ready for review October 4, 2024 04:41
@dsuhinin
Copy link
Collaborator

dsuhinin commented Oct 7, 2024

It feels like you need to re generate mocks.

Copy link
Collaborator

@nojaf nojaf left a comment

Choose a reason for hiding this comment

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

Hi @jescalada, thanks for this contribution!
There are some interesting changes in here which I did not expect.
It would be great to jump on a call sometime and further discuss.

.devcontainer/devcontainer.json Outdated Show resolved Hide resolved
magefiles/tests.go Outdated Show resolved Hide resolved
pkg/tracking/service/tags.go Outdated Show resolved Hide resolved
pkg/tracking/store/sql/tags.go Outdated Show resolved Hide resolved
pkg/tracking/store/sql/tags.go Outdated Show resolved Hide resolved
pkg/tracking/store/sql/tags.go Outdated Show resolved Hide resolved
pkg/tracking/store/sql/tags.go Outdated Show resolved Hide resolved
Signed-off-by: Juan Escalada <[email protected]>
Signed-off-by: Juan Escalada <[email protected]>
Signed-off-by: Juan Escalada <[email protected]>
Signed-off-by: Juan Escalada <[email protected]>
.devcontainer/devcontainer.json Outdated Show resolved Hide resolved
magefiles/tests.go Outdated Show resolved Hide resolved
pkg/protos/scalapb/scalapb.pb.go Outdated Show resolved Hide resolved
Signed-off-by: Juan Escalada <[email protected]>
Signed-off-by: Juan Escalada <[email protected]>
Signed-off-by: Juan Escalada <[email protected]>
Signed-off-by: Juan Escalada <[email protected]>
@jescalada
Copy link
Contributor Author

I managed to get the test_set_tag_validation test to pass, however, I did this via a manual check in /pkg/tracking/service/tags.go. I also added the custom validator for the runId, however I am not sure how to integrate this with the existing code.

Is this meant to be used in our own Go tests? I noticed that for the LogBatch we're doing custom tests in /pkg/validation/validation_test.go.

Copy link
Collaborator

@nojaf nojaf left a comment

Choose a reason for hiding this comment

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

FAILED .mlflow.repo/tests/store/tracking/test_sqlalchemy_store.py::test_set_tag is failing because the test uses monkeypatch.setenv("MLFLOW_TRUNCATE_LONG_VALUES", "true").

@dsuhinin can you give some advice on what should be done in this case.

magefiles/generate/validations.go Outdated Show resolved Hide resolved
pkg/tracking/store/sql/tags.go Outdated Show resolved Hide resolved
pkg/tracking/store/sql/tags.go Outdated Show resolved Hide resolved
@nojaf
Copy link
Collaborator

nojaf commented Oct 10, 2024

Oh and please rebase on latest main.

magefiles/tests.go Outdated Show resolved Hide resolved
magefiles/tests.go Outdated Show resolved Hide resolved
pkg/tracking/store/sql/tags.go Outdated Show resolved Hide resolved
magefiles/tests.go Show resolved Hide resolved
@jescalada jescalada requested a review from nojaf October 16, 2024 02:10
.devcontainer/postCreate.sh Outdated Show resolved Hide resolved
pkg/tracking/store/sql/tags.go Outdated Show resolved Hide resolved
Signed-off-by: Juan Escalada <[email protected]>
Signed-off-by: Juan Escalada <[email protected]>
Signed-off-by: Juan Escalada <[email protected]>
Signed-off-by: Juan Escalada <[email protected]>
Copy link
Collaborator

@nojaf nojaf left a comment

Choose a reason for hiding this comment

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

Thanks!

@nojaf nojaf requested a review from dsuhinin October 16, 2024 11:15
Copy link
Collaborator

@dsuhinin dsuhinin left a comment

Choose a reason for hiding this comment

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

It looks good! Left few minor questions/proposals.

Comment on lines +16 to +19
def test_set_tag(store: SqlAlchemyStore, monkeypatch):
()


Copy link
Collaborator

Choose a reason for hiding this comment

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

So, can we try to have not just an empty test in that case but something like:

run = _run_factory(store)

    tkey = "test tag"
    tval = "a boogie"
    new_val = "new val"
    tag = entities.RunTag(tkey, tval)
    new_tag = entities.RunTag(tkey, new_val)
    store.set_tag(run.info.run_id, tag)
    # Overwriting tags is allowed
    store.set_tag(run.info.run_id, new_tag)
    # test setting tags that are too long fails.
    monkeypatch.setenv("MLFLOW_TRUNCATE_LONG_VALUES", "false")
    with pytest.raises(
        MlflowException, match=f"exceeds the maximum length of {MAX_TAG_VAL_LENGTH} characters"
    ):
        store.set_tag(
            run.info.run_id, entities.RunTag("longTagKey", "a" * (MAX_TAG_VAL_LENGTH + 1))
        )

  
    # test can set tags that are somewhat long
    store.set_tag(run.info.run_id, entities.RunTag("longTagKey", "a" * (MAX_TAG_VAL_LENGTH - 1)))
    run = store.get_run(run.info.run_id)
    assert tkey in run.data.tags
    assert run.data.tags[tkey] == new_val

Copy link
Collaborator

Choose a reason for hiding this comment

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

so without such part which actually failing:

monkeypatch.setenv("MLFLOW_TRUNCATE_LONG_VALUES", "true")
    store.set_tag(run.info.run_id, entities.RunTag("longTagKey", "a" * (MAX_TAG_VAL_LENGTH + 1)))

Copy link
Contributor Author

@jescalada jescalada Oct 19, 2024

Choose a reason for hiding this comment

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

@dsuhinin I just tried implementing this, and it seems to require a lot of test-specific dependencies from the MLflow side. For example, the _run_factory function makes use of another helper function _create_experiments and so on, which would clutter our tests if we ported them over. And they are private so I don't think we have a choice other than to implement them directly on our override_test_sqlalchemy_store.py. I feel that implementing these would clutter that file too much, maybe we could have another file for test utils? 🤔 At any rate, I feel that it would be a pretty large change so we could make a separate issue/PR to sort it out!

Edit: I made an issue for it so that we don't forget: #69

pkg/tracking/store/sql/tags.go Outdated Show resolved Hide resolved
magefiles/tests.go Show resolved Hide resolved
@nojaf nojaf merged commit 7c480fd into mlflow:main Oct 19, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants