Skip to content

Commit 24f54e0

Browse files
committed
[IMP] connector-runner: tiny refactoring in channel name config
1 parent 49080a2 commit 24f54e0

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

connector/jobrunner/channels.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def configure(self, config):
351351
* capacity
352352
* sequential
353353
"""
354-
assert config['name'] == self.fullname
354+
assert self.fullname.endswith(config['name'])
355355
self.capacity = config.get('capacity', None)
356356
self.sequential = bool(config.get('sequential', False))
357357
if self.sequential and self.capacity != 1:
@@ -556,7 +556,7 @@ def parse_simple_config(cls, config_string):
556556
>>> pp(ChannelManager.parse_simple_config('root'))
557557
[{'capacity': 1, 'name': 'root'}]
558558
>>> pp(ChannelManager.parse_simple_config('sub:2'))
559-
[{'capacity': 2, 'name': 'root.sub'}]
559+
[{'capacity': 2, 'name': 'sub'}]
560560
"""
561561
res = []
562562
for channel_config_string in config_string.split(','):
@@ -566,8 +566,6 @@ def parse_simple_config(cls, config_string):
566566
if not name:
567567
raise ValueError('Invalid channel config %s: '
568568
'missing channel name' % config_string)
569-
if not name.startswith('root.') and name != 'root':
570-
name = 'root.' + name
571569
config['name'] = name
572570
if len(config_items) > 1:
573571
capacity = config_items[1]
@@ -610,6 +608,8 @@ def simple_configure(self, config_string):
610608
>>> cm.get_channel_by_name('root.autosub').capacity
611609
>>> cm.get_channel_by_name('root.autosub.sub').capacity
612610
2
611+
>>> cm.get_channel_by_name('autosub.sub').capacity
612+
2
613613
"""
614614
for config in ChannelManager.parse_simple_config(config_string):
615615
self.get_channel_from_config(config)
@@ -676,9 +676,7 @@ def get_channel_by_name(self, channel_name, autocreate=False):
676676
if not autocreate:
677677
raise ChannelNotFound('Channel %s not found' % channel_name)
678678
parent = self._root_channel
679-
for subchannel_name in channel_name.split('.'):
680-
if subchannel_name == 'root':
681-
continue
679+
for subchannel_name in channel_name.split('.')[1:]:
682680
subchannel = parent.get_subchannel_by_name(subchannel_name)
683681
if not subchannel:
684682
subchannel = Channel(subchannel_name, parent, capacity=None)

0 commit comments

Comments
 (0)