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

Use name argument with Scheduler.remove_plugin calls #5260

Merged
merged 5 commits into from
Aug 26, 2021

Conversation

douglasdavis
Copy link
Member

@douglasdavis douglasdavis commented Aug 24, 2021

  • Closes #xxxx
  • Tests added / passed
  • Passes black distributed / flake8 distributed / isort distributed

After #5120 we added a warning about removing plugins by instance instead of by name; there are a few places distributed where the warning was getting triggered; this should remove those warnings.

Copy link
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

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

Thanks @douglasdavis! Looking at this build there are still a few Scheduler.remove_plugin-related warnings:


distributed/diagnostics/tests/test_progress_stream.py::test_progress_stream
distributed/diagnostics/tests/test_scheduler_plugin.py::test_async_add_remove_worker
  /home/runner/work/distributed/distributed/distributed/scheduler.py:5507: FutureWarning: Removing scheduler plugins by value is deprecated and will be disabled in a future release. Please remove scheduler plugins by name instead.
    warnings.warn(

distributed/diagnostics/tests/test_progress_stream.py::test_progress_stream
  /home/runner/work/distributed/distributed/distributed/scheduler.py:5525: FutureWarning: Removing scheduler plugins by value is deprecated and will be disabled in a future release. Please remove scheduler plugins by name instead.
    warnings.warn(

@douglasdavis
Copy link
Member Author

Thanks @jrbourbeau! I think I could use your opinion on how to deal with these.

  1. for test_progress_stream here's the line where remove_plugin is used:

    "teardown": dumps_function(remove_plugin),

    Should we wrap this in functools.partial?

  2. for test_async_add_remove_worker we're testing the exception for multiple instances of the same plugin (which should be phased out with the new name behavior where repeated names are overwritten). Should we just remove this part of the test (since it's testing an exception raising in a scenario that is no longer supported)?

@jrbourbeau
Copy link
Member

  1. It looks like remove_plugin will forward keyword arguments

    def remove_plugin(*args, **kwargs):
    # Wrapper function around `Scheduler.remove_plugin` to avoid raising a
    # `PicklingError` when using a cythonized scheduler
    return Scheduler.remove_plugin(*args, **kwargs)

    Can we forward the correct name= keyword in this case?

  2. with pytest.warns(..., match="..."): is probably what we want here. That will let us continue to test the deprecated behavior, and ensure that any appropriate warnings are emitted.

@douglasdavis
Copy link
Member Author

Thanks! I think (2) is good to go. for (1) I went ahead and passed the name= via functools.partial and dropped the *args (passed to remove_plugin) in the Scheduler.remove_plugin call.

@@ -117,7 +117,8 @@ async def start(self, scheduler):
s.add_plugin(plugin)
s.add_plugin(plugin, name="another")
with pytest.raises(ValueError) as excinfo:
s.remove_plugin(plugin)
with pytest.warns(UserWarning, match="Removing scheduler plugins by value"):
Copy link
Member

Choose a reason for hiding this comment

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

Hmm based on

warnings.warn(
"Removing scheduler plugins by value is deprecated and will be disabled "
"in a future release. Please remove scheduler plugins by name instead.",
category=FutureWarning,
)

I would have expected this to emit a FutureWarning instead of a UserWarning

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed- I just made the adjustment. I wonder why it passed before

Copy link
Member

Choose a reason for hiding this comment

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

Interesting. This might be a bug in pytest (I opened up pytest-dev/pytest#9036). If you change the order of pytest.raises and pytest.warns, then things behave as expected

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting find! Just pushed a commit to swap the order.

@douglasdavis douglasdavis mentioned this pull request Aug 25, 2021
3 tasks
@jrbourbeau
Copy link
Member

Thanks for the updates @douglasdavis! There are some tests that have begun failing which are, seemingly, unrelated to the changes here. I'm running CI against the main branch over in #5268 to further clarify.

@jrbourbeau
Copy link
Member

Hrm, looks like these failures are unrelated...

@jrbourbeau
Copy link
Member

Alright, merging main should fix the unrelated test failures

Copy link
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

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

Thanks @douglasdavis! Will merge once CI finishes

@jrbourbeau jrbourbeau changed the title Use name argument with Scheduler.remove_plugin calls (silences warnings) Use name argument with Scheduler.remove_plugin calls Aug 26, 2021
@jrbourbeau jrbourbeau merged commit eedbd4b into dask:main Aug 26, 2021
@douglasdavis douglasdavis deleted the remove-plugin-use-name branch August 26, 2021 18:42
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.

2 participants