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

#234 use master/worker terminology #268

Merged
merged 8 commits into from
Feb 6, 2018
Merged

#234 use master/worker terminology #268

merged 8 commits into from
Feb 6, 2018

Conversation

feuillemorte
Copy link
Contributor

Use master/worker terminologi in arguments

@@ -46,7 +46,7 @@ def __init__(self, config):
self._failed_collection_errors = {}
self._active_nodes = set()
self._failed_nodes_count = 0
self._max_slave_restart = self.config.getoption('max_slave_restart')
self._max_slave_restart = self.config.getoption('max_worker_restart')
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better if the code was also changed to use worker rather than slave. Does this code also support the old command line option to stop everything breaking during transition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I just renamed to new method. Do you need support old value? I'll add support

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not in charge here, but I think it would be best if a deprecation notice is used for the old command so that it is still supported for a couple of releases before being dropped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be better if the code was also changed to use worker rather than slave

I didn't change another code bacause it must be changed in pytest repo else. Do you think I need rename all code?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant, can we stop using "slave" in the xdist code everywhere, and not just in the messages seen by users? Using worker externally and slave internally seems like a weird inconsistency when the aim is to remove slave nomenclature everywhere. I wasn't saying anything about other pytest repos.

PS Thanks for tackling this. I really do appreciate this getting done since I haven't had a chance to have a go myself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll remove all "slave" from code, but there is one file which uses in pytest. So, I need to create commit in pytest repo else

Copy link
Member

Choose a reason for hiding this comment

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

@feuillemorte you mean the slaveinput attribute of the config object? I think for that case we can have both names, slaveinput and workerinput which point to the same dictionary so we can keep backward compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicoddemus ok, thank you!

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Thanks a ton @feuillemorte for tackling this, we really appreciate it.

Please see my comments. 😁

xdist/plugin.py Outdated
@@ -26,8 +26,8 @@ def pytest_addoption(parser):
help="shortcut for '--dist=load --tx=NUM*popen', "
"you can use 'auto' here for auto detection CPUs number on "
"host system")
group.addoption('--max-slave-restart', action="store", default=None,
help="maximum number of slaves that can be restarted "
group.addoption('--max-worker-restart', action="store", default=None,
Copy link
Member

Choose a reason for hiding this comment

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

IIRC you can pass multiple values here to support aliases:

group.addoption('--max-worker-restart', '--max-slave-restart', action="store", ...

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 want to add dest value like:

group.addoption('--max-worker-restart', '--max-slave-restart', action="store", default=None, dest="maxworkerrestart", help="maximum number of workers that can be restarted " "when crashed (set to zero to disable this feature)\n" "'--max-slave-restart' option is deprecated and will be removed in next versions")

Copy link
Member

Choose a reason for hiding this comment

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

Seems good, perhaps just changing "in next versions" to "in a future release". 👍

@@ -46,7 +46,7 @@ def __init__(self, config):
self._failed_collection_errors = {}
self._active_nodes = set()
self._failed_nodes_count = 0
self._max_slave_restart = self.config.getoption('max_slave_restart')
self._max_slave_restart = self.config.getoption('max_worker_restart')
Copy link
Member

Choose a reason for hiding this comment

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

@feuillemorte you mean the slaveinput attribute of the config object? I think for that case we can have both names, slaveinput and workerinput which point to the same dictionary so we can keep backward compatibility.

@feuillemorte
Copy link
Contributor Author

Please, test locally. Tests ran successfuly, but.. :)

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Thanks @feuillemorte for the follow up! 😁

Please take a look at my comments when you have the time.

@@ -26,7 +26,7 @@ def __str__(self):
return "<EventCall %s(**%s)>" % (self.name, self.kwargs)


class SlaveSetup:
class workerSetup:
Copy link
Member

Choose a reason for hiding this comment

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

WorkerSetup

class TestSlaveInteractor:
def test_basic_collect_and_runtests(self, slave):
slave.testdir.makepyfile("""
class TestworkerInteractor:
Copy link
Member

Choose a reason for hiding this comment

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

TestWorkerInteractor



class SlaveFailSession:
class workerFailSession:
Copy link
Member

Choose a reason for hiding this comment

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

WorkerFailSession

xdist/remote.py Outdated
@@ -14,11 +14,11 @@
import pytest


class SlaveInteractor:
class workerInteractor:
Copy link
Member

Choose a reason for hiding this comment

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

WorkerInteractor

@@ -201,19 +201,19 @@ def make_reltoroot(roots, args):
return result


class SlaveController(object):
class workerController(object):
Copy link
Member

Choose a reason for hiding this comment

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

WorkerController

ENDMARK = -1

def __init__(self, nodemanager, gateway, config, putevent):
self.nodemanager = nodemanager
self.putevent = putevent
self.gateway = gateway
self.config = config
self.slaveinput = {'slaveid': gateway.id,
'slavecount': len(nodemanager.specs)}
self.workerinput = {'workerid': gateway.id,
Copy link
Member

Choose a reason for hiding this comment

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

Please add an alias here for backward compatibility:

# deprecated name, backward compatibility only
self.slaveinput = workerinput  

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

Choose a reason for hiding this comment

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

this dict also need the old names (slaveid and slavecount)

and we likely need to keep those for around 5 years at least

i propose adding as is and later on following up with a dict subclass that gives deprecation warnings in a few years

Copy link
Member

Choose a reason for hiding this comment

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

Ah good catch, I missed those. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

config.slaveoutput = {}
interactor = SlaveInteractor(config, channel)
config.workerinput = workerinput
config.workeroutput = {}
Copy link
Member

Choose a reason for hiding this comment

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

Please add aliases here for backward compatibility:

# deprecated name, backward compatibility only
config.slaveinput = config.workerinput  
config.slaveoutput = config.workeroutput

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@feuillemorte
Copy link
Contributor Author

how to use linter? :)
tox -e linting ERROR: unknown environment 'linting'

@nicoddemus
Copy link
Member

how to use linter? :)

tox -l shows all environments, in pytest-xdist the linter is called flakes:

tox -e flakes

@nicoddemus
Copy link
Member

Thanks @feuillemorte for the quick update!

LGTM so far, let's wait for @RonnyPfannschmidt's review.

@feuillemorte
Copy link
Contributor Author

@timj please, approve too

@nicoddemus
Copy link
Member

Added an explicit test for backward compatibility of the old slaveinput name.

Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

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

i believe we covered all that needs covering now
so this is good to go, thanks 👍

i do have a lingering fear that a minor detail is missing, but thise should be sortable very easily

@nicoddemus nicoddemus merged commit 23ce450 into pytest-dev:master Feb 6, 2018
@feuillemorte feuillemorte deleted the 234-master-worker-terminology branch February 6, 2018 09:28
@RonnyPfannschmidt
Copy link
Member

@feuillemorte great work, thanks again 👍

@ionelmc
Copy link
Member

ionelmc commented Feb 26, 2018

Do we really need to also rename the --max-slave-restart? I don't really like the churn of editing config files in a dozen projects.

@nicoddemus
Copy link
Member

--max-slave-restart was kept as an alias to --max-worker-restart:

group.addoption('--max-worker-restart', '--max-slave-restart', action="store", default=None,
dest="maxworkerrestart",

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.

5 participants