<s> """<STR_LIT:U+0020>""" <EOL> import os <EOL> from pulsar . client import action_mapper <EOL> from pulsar . client import staging <EOL> from pulsar . client . staging import PulsarOutputs <EOL> from pulsar . client . staging . down import ResultsCollector <EOL> import logging <EOL> log = logging . getLogger ( __name__ ) <EOL> def postprocess ( job_directory , action_executor ) : <EOL> try : <EOL> staging_config = job_directory . load_metadata ( "<STR_LIT>" , None ) <EOL> collected = __collect_outputs ( job_directory , staging_config , action_executor ) <EOL> return collected <EOL> finally : <EOL> job_directory . write_file ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> return False <EOL> def __collect_outputs ( job_directory , staging_config , action_executor ) : <EOL> collected = True <EOL> if "<STR_LIT>" in staging_config : <EOL> file_action_mapper = action_mapper . FileActionMapper ( config = staging_config [ "<STR_LIT>" ] ) <EOL> client_outputs = staging . ClientOutputs . from_dict ( staging_config [ "<STR_LIT>" ] ) <EOL> pulsar_outputs = __pulsar_outputs ( job_directory ) <EOL> output_collector = PulsarServerOutputCollector ( job_directory , action_executor ) <EOL> results_collector = ResultsCollector ( output_collector , file_action_mapper , client_outputs , pulsar_outputs ) <EOL> collection_failure_exceptions = results_collector . collect ( ) <EOL> if collection_failure_exceptions : <EOL> log . warn ( "<STR_LIT>" % collection_failure_exceptions ) <EOL> collected = False <EOL> return collected <EOL> class PulsarServerOutputCollector ( object ) : <EOL> def __init__ ( self , job_directory , action_executor ) : <EOL> self . job_directory = job_directory <EOL> self . action_executor = action_executor <EOL> def collect_output ( self , results_collector , output_type , action , name ) : <EOL> if action . staging_action_local : <EOL> return <EOL> if not name : <EOL> name = os . path . basename ( action . path ) <EOL> pulsar_path = self . job_directory . calculate_path ( name , output_type ) <EOL> description = "<STR_LIT>" % ( pulsar_path , action ) <EOL> self . action_executor . execute ( lambda : action . write_from_path ( pulsar_path ) , description ) <EOL> def __pulsar_outputs ( job_directory ) : <EOL> working_directory_contents = job_directory . working_directory_contents ( ) <EOL> output_directory_contents = job_directory . outputs_directory_contents ( ) <EOL> metadata_directory_contents = job_directory . metadata_directory_contents ( ) <EOL> return PulsarOutputs ( <EOL> working_directory_contents , <EOL> output_directory_contents , <EOL> metadata_directory_contents , <EOL> ) <EOL> __all__ = [ '<STR_LIT>' ] </s>
