@@ -138,7 +138,7 @@ def __len__(self):
138138 def set_flags (self , ** kwargs ):
139139 """set my attribute flags by keyword.
140140
141- Views determine behavior with a few attributes (`block`, `track`, etc.).
141+ Views determine behavior with a few attributes (`block`, `track`, `label`, etc.).
142142 These attributes can be set all at once by name with this method.
143143
144144 Parameters
@@ -149,6 +149,8 @@ def set_flags(self, **kwargs):
149149 whether to create a MessageTracker to allow the user to
150150 safely edit after arrays and buffers during non-copying
151151 sends.
152+ label : str
153+ set an optional user-defined task identifier
152154 """
153155 for name , value in kwargs .items ():
154156 if name not in self ._flag_names :
@@ -557,6 +559,8 @@ def _really_apply(
557559 whether to block
558560 track : bool [default: self.track]
559561 whether to ask zmq to track the message, for safe non-copying sends
562+ label : str [default self.label]
563+ set an optional user-defined task identifier
560564
561565 Returns
562566 -------
@@ -642,6 +646,8 @@ def map(
642646 Only for zero-copy sends such as numpy arrays that are going to be modified in-place.
643647 return_exceptions : bool [default False]
644648 Return remote Exceptions in the result sequence instead of raising them.
649+ label : str [default self.label]
650+ set an optional user-defined task identifier
645651
646652 Returns
647653 -------
@@ -672,7 +678,7 @@ def map(
672678
673679 @sync_results
674680 @save_ids
675- def execute (self , code , silent = True , targets = None , block = None ):
681+ def execute (self , code , silent = True , targets = None , block = None , label = None ):
676682 """Executes `code` on `targets` in blocking or nonblocking manner.
677683
678684 ``execute`` is always `bound` (affects engine namespace)
@@ -681,18 +687,21 @@ def execute(self, code, silent=True, targets=None, block=None):
681687 ----------
682688 code : str
683689 the code string to be executed
684- block : bool
690+ block : bool [default self.block]
685691 whether or not to wait until done to return
686- default: self.block
692+ label : str [default self.label]
693+ set an optional user-defined task identifier
687694 """
688695 block = self .block if block is None else block
689696 targets = self .targets if targets is None else targets
697+ label = self .label if label is None else label
698+ metadata = dict (label = label )
690699
691700 _idents , _targets = self .client ._build_targets (targets )
692701 futures = []
693702 for ident in _idents :
694703 future = self .client .send_execute_request (
695- self ._socket , code , silent = silent , ident = ident
704+ self ._socket , code , silent = silent , ident = ident , metadata = metadata
696705 )
697706 futures .append (future )
698707 if isinstance (targets , int ):
@@ -708,7 +717,7 @@ def execute(self, code, silent=True, targets=None, block=None):
708717 pass
709718 return ar
710719
711- def run (self , filename , targets = None , block = None ):
720+ def run (self , filename , targets = None , block = None , label = None ):
712721 """Execute contents of `filename` on my engine(s).
713722
714723 This simply reads the contents of the file and calls `execute`.
@@ -723,13 +732,15 @@ def run(self, filename, targets=None, block=None):
723732 block : bool
724733 whether or not to wait until done
725734 default: self.block
735+ label : str
736+ set an optional user-defined task identifier
726737
727738 """
728739 with open (filename ) as f :
729740 # add newline in case of trailing indented whitespace
730741 # which will cause SyntaxError
731742 code = f .read () + '\n '
732- return self .execute (code , block = block , targets = targets )
743+ return self .execute (code , block = block , targets = targets , label = label )
733744
734745 def update (self , ns ):
735746 """update remote namespace with dict `ns`
@@ -1076,7 +1087,6 @@ def map(
10761087 block = None ,
10771088 track = False ,
10781089 return_exceptions = False ,
1079- label = None ,
10801090 ):
10811091 """Parallel version of builtin `map`, using this View's `targets`.
10821092
@@ -1297,6 +1307,8 @@ def set_flags(self, **kwargs):
12971307 DependencyTimeout.
12981308 retries : int
12991309 Number of times a task will be retried on failure.
1310+ label : str
1311+ set an optional user-defined task identifier
13001312 """
13011313
13021314 super ().set_flags (** kwargs )
@@ -1348,6 +1360,8 @@ def _really_apply(
13481360 whether to block
13491361 track : bool [default: self.track]
13501362 whether to ask zmq to track the message, for safe non-copying sends
1363+ label : str [default self.label]
1364+ set an optional user-defined task identifier
13511365 !!!!!! TODO : THE REST HERE !!!!
13521366
13531367 Returns
@@ -1470,6 +1484,8 @@ def map(
14701484
14711485 return_exceptions: bool [default False]
14721486 Return Exceptions instead of raising on the first exception.
1487+ label : str [default self.label]
1488+ set an optional user-defined task identifier
14731489
14741490 Returns
14751491 -------
0 commit comments