Skip to content

Hardcoded /tmp/ default paths in flag definitions across multiple models #3543

@kredd2506

Description

@kredd2506

Description

Multiple files across models/official/ use hardcoded /tmp/ paths as default values in flag definitions. This is not portable across platforms and can cause confusion or silent failures.

Affected files

EfficientNetmodels/official/efficientnet/eval_ckpt_main.py

flags.DEFINE_string('ckpt_dir', '/tmp/ckpt/', ...)
flags.DEFINE_string('example_img', '/tmp/panda.jpg', ...)
flags.DEFINE_string('labels_map_file', '/tmp/labels_map.txt', ...)

EfficientNetmodels/official/efficientnet/inspect_model_architecture.py

flags.DEFINE_string('output_tflite', '/tmp/model.tflite', ...)

MnasNetmodels/official/mnasnet/eval_ckpt_main.py

flags.DEFINE_string('ckpt_dir', '/tmp/ckpt/', ...)
flags.DEFINE_string('example_img', '/tmp/panda.jpg', ...)
flags.DEFINE_string('labels_map_file', '/tmp/labels_map.txt', ...)

Detectionmodels/official/detection/inference.py, inference_saved_model.py

flags.DEFINE_string('output_html', '/tmp/test.html', ...)

Fashionpediamodels/official/detection/projects/fashionpedia/inference.py, inference_saved_model.py

flags.DEFINE_string('output_html', '/tmp/test.html', ...)
flags.DEFINE_string('output_file', '/tmp/res.npy', ...)

Impact

  • Not portable to Windows or environments where /tmp may not be writable
  • Users may unknowingly overwrite each other's files in shared environments
  • Defaults like /tmp/panda.jpg imply a file exists there, with no guidance on how to obtain it

Suggested Fix

Use None as the default and require the user to specify paths explicitly, or use tempfile.mkdtemp() / platform-agnostic alternatives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions