Beispiel #1
0
    def verify_paths(self, config, p):
        keep_temp = config.get('keep_temp', False)
        # clean out WORKING_DIR if we're not keeping temp files:
        if os.path.exists(p.WORKING_DIR) and not \
            (keep_temp or p.WORKING_DIR == p.OUTPUT_DIR):
            gfdl_util.rmtree_wrapper(p.WORKING_DIR)

        try:
            for dir_name, create_ in (('CODE_ROOT', False), ('OBS_DATA_REMOTE',
                                                             False),
                                      ('OBS_DATA_ROOT',
                                       True), ('MODEL_DATA_ROOT',
                                               True), ('WORKING_DIR', True)):
                util.check_dir(p, dir_name, create=create_)
        except Exception as exc:
            _log.fatal((f"Input settings for {dir_name} mis-specified (caught "
                        f"{repr(exc)}.)"))
            util.exit_handler(code=1)

        # Use GCP to create OUTPUT_DIR on a volume that may be read-only
        if not os.path.exists(p.OUTPUT_DIR):
            gfdl_util.make_remote_dir(p.OUTPUT_DIR,
                                      self.timeout,
                                      self.dry_run,
                                      log=_log)
Beispiel #2
0
 def verify_paths(self, config, p):
     keep_temp = config.get('keep_temp', False)
     # clean out WORKING_DIR if we're not keeping temp files:
     if os.path.exists(p.WORKING_DIR) and not \
         (keep_temp or p.WORKING_DIR == p.OUTPUT_DIR):
         gfdl_util.rmtree_wrapper(p.WORKING_DIR)
     util.check_dirs(p.CODE_ROOT, p.OBS_DATA_REMOTE, create=False)
     util.check_dirs(p.MODEL_DATA_ROOT, p.OBS_DATA_ROOT, p.WORKING_DIR, 
         create=True)
     # Use GCP to create OUTPUT_DIR on a volume that may be read-only
     if not os.path.exists(p.OUTPUT_DIR):
         gfdl_util.make_remote_dir(p.OUTPUT_DIR, self.timeout, self.dry_run)
Beispiel #3
0
 def parse_env_vars(self, cli_obj):
     super(GFDLMDTFFramework, self).parse_env_vars(cli_obj)
     # set temp directory according to where we're running
     if gfdl_util.running_on_PPAN():
         gfdl_tmp_dir = cli_obj.config.get('GFDL_PPAN_TEMP', '$TMPDIR')
     else:
         gfdl_tmp_dir = cli_obj.config.get('GFDL_WS_TEMP', '$TMPDIR')
     gfdl_tmp_dir = util.resolve_path(
         gfdl_tmp_dir, root_path=self.code_root, env=self.global_env_vars
     )
     if not os.path.isdir(gfdl_tmp_dir):
         gfdl_util.make_remote_dir(gfdl_tmp_dir)
     tempfile.tempdir = gfdl_tmp_dir
     os.environ['MDTF_TMPDIR'] = gfdl_tmp_dir
     self.global_env_vars['MDTF_TMPDIR'] = gfdl_tmp_dir
Beispiel #4
0
    def pre_run_setup(self):
        """Extra code only applicable in frepp cooperative mode. If this code is
        called, all the POD's model data has been generated. Write a placeholder
        directory to POD_OUT_DIR, so if frepp invokes the MDTF package again
        while we're running, only our results will be written to the overall
        output.
        """
        super(GfdlDiagnostic, self).pre_run_setup()

        config = core.ConfigManager()
        frepp_mode = config.get('frepp', False)
        if frepp_mode and not os.path.exists(self.POD_OUT_DIR):
            try:
                gfdl_util.make_remote_dir(self.POD_OUT_DIR, log=self.log)
                self._has_placeholder = True
            except Exception as exc:
                chained_exc = util.chain_exc(exc, (f"Making output directory at "
                    f"{self.POD_OUT_DIR}."), util.PodRuntimeError)
                self.deactivate(chained_exc)