Skip to content

#234 use master/worker terminology#268

Merged
nicoddemus merged 8 commits intopytest-dev:masterfrom
feuillemorte:234-master-worker-terminology
Feb 6, 2018
Merged

#234 use master/worker terminology#268
nicoddemus merged 8 commits intopytest-dev:masterfrom
feuillemorte:234-master-worker-terminology

Conversation

@feuillemorte
Copy link
Copy Markdown
Contributor

Use master/worker terminologi in arguments

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
"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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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". 👍

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
Copy Markdown
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
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
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.



class SlaveSetup:
class workerSetup:
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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


class SlaveInteractor:
class workerInteractor:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

WorkerInteractor



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

Choose a reason for hiding this comment

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

WorkerController

self.config = config
self.slaveinput = {'slaveid': gateway.id,
'slavecount': len(nodemanager.specs)}
self.workerinput = {'workerid': gateway.id,
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@nicoddemus
Copy link
Copy Markdown
Member

how to use linter? :)

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

tox -e flakes

@nicoddemus
Copy link
Copy Markdown
Member

Thanks @feuillemorte for the quick update!

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

@feuillemorte
Copy link
Copy Markdown
Contributor Author

@timj please, approve too

@nicoddemus
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
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
Copy Markdown
Member

@feuillemorte great work, thanks again 👍

@ionelmc
Copy link
Copy Markdown
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
Copy Markdown
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