"git@developer.sourcefind.cn:OpenDAS/torch-scatter.git" did not exist on "aae9e125b41cf37af9df5bc108e63da644483b1d"
Commit 1980a0da authored by Shawn Wang's avatar Shawn Wang
Browse files

Add comments, exit async process after waiting for flagfile for too long and...

Add comments, exit async process after waiting for flagfile for too long and make directory for data_dir in case it does not exist.
parent 5d497296
...@@ -441,14 +441,21 @@ def _generation_loop(num_workers, # type: int ...@@ -441,14 +441,21 @@ def _generation_loop(num_workers, # type: int
def _parse_flagfile(): def _parse_flagfile():
"""Fill flags with flagfile.""" """Fill flags with flagfile written by the main process."""
flagfile = os.path.join(flags.FLAGS.data_dir, flagfile = os.path.join(flags.FLAGS.data_dir,
rconst.FLAGFILE) rconst.FLAGFILE)
tf.logging.info("Waiting for flagfile to appear at {}..." tf.logging.info("Waiting for flagfile to appear at {}..."
.format(flagfile)) .format(flagfile))
start_time = time.time()
while not tf.gfile.Exists(flagfile): while not tf.gfile.Exists(flagfile):
if time.time() - start_time > rconst.TIMEOUT_SECONDS:
log_msg("Waited more than {} seconds. Concluding that this "
"process is orphaned and exiting gracefully."
.format(rconst.TIMEOUT_SECONDS))
sys.exit()
time.sleep(1) time.sleep(1)
tf.logging.info("flagfile found.") tf.logging.info("flagfile found.")
# This overrides FLAGS with flags from flagfile.
flags.FLAGS([__file__, "--flagfile", flagfile]) flags.FLAGS([__file__, "--flagfile", flagfile])
......
...@@ -450,6 +450,7 @@ def instantiate_pipeline(dataset, data_dir, batch_size, eval_batch_size, ...@@ -450,6 +450,7 @@ def instantiate_pipeline(dataset, data_dir, batch_size, eval_batch_size,
} }
if ncf_dataset.deterministic: if ncf_dataset.deterministic:
flags_["seed"] = stat_utils.random_int32() flags_["seed"] = stat_utils.random_int32()
tf.gfile.MakeDirs(flags.FLAGS.data_dir)
# We write to a temp file then atomically rename it to the final file, # We write to a temp file then atomically rename it to the final file,
# because writing directly to the final file can cause the data generation # because writing directly to the final file can cause the data generation
# async process to read a partially written JSON file. # async process to read a partially written JSON file.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment