@@ -113,26 +113,25 @@ def create_harness(environment, dry_run=False):
113113 _LOGGER .info ('semi_persistent_directory: %s' , semi_persistent_directory )
114114 _worker_id = environment .get ('WORKER_ID' , None )
115115
116- if pickle_library != pickler .USE_CLOUDPICKLE :
117- try :
118- _load_main_session (semi_persistent_directory )
119- except LoadMainSessionException :
120- exception_details = traceback .format_exc ()
121- _LOGGER .error (
122- 'Could not load main session: %s' , exception_details , exc_info = True )
123- raise
124- except Exception : # pylint: disable=broad-except
125- summary = (
126- "Could not load main session. Inspect which external dependencies "
127- "are used in the main module of your pipeline. Verify that "
128- "corresponding packages are installed in the pipeline runtime "
129- "environment and their installed versions match the versions used in "
130- "pipeline submission environment. For more information, see: https://"
131- "beam.apache.org/documentation/sdks/python-pipeline-dependencies/" )
132- _LOGGER .error (summary , exc_info = True )
133- exception_details = traceback .format_exc ()
134- deferred_exception = LoadMainSessionException (
135- f"{ summary } { exception_details } " )
116+ try :
117+ _load_main_session (semi_persistent_directory )
118+ except LoadMainSessionException :
119+ exception_details = traceback .format_exc ()
120+ _LOGGER .error (
121+ 'Could not load main session: %s' , exception_details , exc_info = True )
122+ raise
123+ except Exception : # pylint: disable=broad-except
124+ summary = (
125+ "Could not load main session. Inspect which external dependencies "
126+ "are used in the main module of your pipeline. Verify that "
127+ "corresponding packages are installed in the pipeline runtime "
128+ "environment and their installed versions match the versions used in "
129+ "pipeline submission environment. For more information, see: https://"
130+ "beam.apache.org/documentation/sdks/python-pipeline-dependencies/" )
131+ _LOGGER .error (summary , exc_info = True )
132+ exception_details = traceback .format_exc ()
133+ deferred_exception = LoadMainSessionException (
134+ f"{ summary } { exception_details } " )
136135
137136 _LOGGER .info (
138137 'Pipeline_options: %s' ,
@@ -356,6 +355,14 @@ class LoadMainSessionException(Exception):
356355
357356def _load_main_session (semi_persistent_directory ):
358357 """Loads a pickled main session from the path specified."""
358+ if pickler .is_currently_dill ():
359+ warn_msg = ' Functions defined in __main__ (interactive session) may fail.'
360+ err_msg = ' Functions defined in __main__ (interactive session) will ' \
361+ 'almost certainly fail.'
362+ elif pickler .is_currently_cloudpickle ():
363+ warn_msg = ' User registered objects (e.g. schema, logical type) through' \
364+ 'registeries may not be effective'
365+ err_msg = ''
359366 if semi_persistent_directory :
360367 session_file = os .path .join (
361368 semi_persistent_directory , 'staged' , names .PICKLED_MAIN_SESSION_FILE )
@@ -365,21 +372,18 @@ def _load_main_session(semi_persistent_directory):
365372 # This can happen if the worker fails to download the main session.
366373 # Raise a fatal error and crash this worker, forcing a restart.
367374 if os .path .getsize (session_file ) == 0 :
368- # Potenitally transient error, unclear if still happening.
369- raise LoadMainSessionException (
370- 'Session file found, but empty: %s. Functions defined in __main__ '
371- '(interactive session) will almost certainly fail.' %
372- (session_file , ))
373- pickler .load_session (session_file )
375+ if pickler .is_currently_dill ():
376+ # Potenitally transient error, unclear if still happening.
377+ raise LoadMainSessionException (
378+ 'Session file found, but empty: %s.%s' % (session_file , err_msg ))
379+ else :
380+ _LOGGER .warning ('Empty session file: %s.%s' , warn_msg , session_file )
381+ else :
382+ pickler .load_session (session_file )
374383 else :
375- _LOGGER .warning (
376- 'No session file found: %s. Functions defined in __main__ '
377- '(interactive session) may fail.' ,
378- session_file )
384+ _LOGGER .warning ('No session file found: %s.%s' , warn_msg , session_file )
379385 else :
380- _LOGGER .warning (
381- 'No semi_persistent_directory found: Functions defined in __main__ '
382- '(interactive session) may fail.' )
386+ _LOGGER .warning ('No semi_persistent_directory found: %s' , warn_msg )
383387
384388
385389if __name__ == '__main__' :
0 commit comments