11import logging
22import parsl
33import time
4- import zmq
54from typing import Dict , List , Sequence , Optional , Union
65
76from parsl .jobs .states import JobStatus , JobState
1716
1817
1918class PolledExecutorFacade :
20- def __init__ (self , executor : BlockProviderExecutor , dfk : Optional ["parsl.dataflow.dflow.DataFlowKernel " ] = None ):
19+ def __init__ (self , executor : BlockProviderExecutor , monitoring : Optional ["parsl.monitoring.radios.MonitoringRadio " ] = None ):
2120 self ._executor = executor
2221 self ._last_poll_time = 0.0
2322 self ._status = {} # type: Dict[str, JobStatus]
24-
25- # Create a ZMQ channel to send poll status to monitoring
26-
27- self .hub_channel : Optional [zmq .Socket ]
28-
29- if dfk and dfk .monitoring is not None :
30- hub_address = dfk .hub_address
31- hub_port = dfk .hub_zmq_port
32- context = zmq .Context ()
33- self .hub_channel = context .socket (zmq .DEALER )
34- self .hub_channel .set_hwm (0 )
35- self .hub_channel .connect ("tcp://{}:{}" .format (hub_address , hub_port ))
36- logger .info ("Monitoring enabled on job status poller" )
37- else :
38- self .hub_channel = None
23+ self ._monitoring = monitoring
3924
4025 def poll (self ) -> None :
4126 now = time .time ()
@@ -54,10 +39,10 @@ def poll(self) -> None:
5439
5540 def send_monitoring_info (self , status : Dict ) -> None :
5641 # Send monitoring info for HTEX when monitoring enabled
57- if self .hub_channel :
42+ if self ._monitoring :
5843 msg = self ._executor .create_monitoring_info (status )
5944 logger .debug ("Sending message {} to hub from job status poller" .format (msg ))
60- self .hub_channel . send_pyobj ((MessageType .BLOCK_INFO , msg ))
45+ self ._monitoring . send ((MessageType .BLOCK_INFO , msg ))
6146
6247 @property
6348 def status (self ) -> Dict [str , JobStatus ]:
@@ -107,9 +92,9 @@ def __repr__(self) -> str:
10792class JobStatusPoller (Timer ):
10893 def __init__ (self , * , strategy : Optional [str ], max_idletime : float ,
10994 strategy_period : Union [float , int ],
110- dfk : Optional ["parsl.dataflow.dflow.DataFlowKernel " ] = None ) -> None :
95+ monitoring : Optional ["parsl.monitoring.radios.MonitoringRadio " ] = None ) -> None :
11196 self ._executor_facades = [] # type: List[PolledExecutorFacade]
112- self .dfk = dfk
97+ self .monitoring = monitoring
11398 self ._strategy = Strategy (strategy = strategy ,
11499 max_idletime = max_idletime )
115100 super ().__init__ (self .poll , interval = strategy_period , name = "JobStatusPoller" )
@@ -131,7 +116,7 @@ def add_executors(self, executors: Sequence[BlockProviderExecutor]) -> None:
131116 for executor in executors :
132117 if executor .status_polling_interval > 0 :
133118 logger .debug ("Adding executor {}" .format (executor .label ))
134- self ._executor_facades .append (PolledExecutorFacade (executor , self .dfk ))
119+ self ._executor_facades .append (PolledExecutorFacade (executor , self .monitoring ))
135120 self ._strategy .add_executors (executors )
136121
137122 def close (self ):
0 commit comments