Updated on 2026-07-27 GMT+08:00

Mapping Between mox.file and Local APIs and Switchover

API Mapping

  • Python: local file operation APIs of Python. The APIs can be shifted to the corresponding MoXing file operation APIs (mox.file) by one click.
  • mox.file: file operation APIs in the MoXing framework, which have a one-to-one mapping relationship with Python APIs.
  • tf.gfile: TensorFlow file operation APIs that have the same functions as the MoXing file operation APIs. In MoXing, the file operation APIs will not be automatically switched to the TensorFlow APIs. The following table only shows the similar functions to help you quickly understand the functions of the MoXing file operation APIs.
Table 1 API mapping

Python (Local File Operation API)

mox.file (MoXing File Operation API)

tf.gfile (TensorFlow File Operation API)

glob.glob

mox.file.glob

tf.gfile.Glob

os.listdir

mox.file.list_directory(..., recursive=False)

tf.gfile.ListDirectory

os.makedirs

mox.file.make_dirs

tf.gfile.MakeDirs

os.mkdir

mox.file.mk_dir

tf.gfile.MkDir

os.path.exists

mox.file.exists

tf.gfile.Exists

os.path.getsize

mox.file.get_size

-

os.path.isdir

mox.file.is_directory

tf.gfile.IsDirectory

os.remove

mox.file.remove(..., recursive=False)

tf.gfile.Remove

os.rename

mox.file.rename

tf.gfile.Rename

os.scandir

mox.file.scan_dir

-

os.stat

mox.file.stat (st_mtime is the GMT time.)

tf.gfile.Stat

os.walk

mox.file.walk

tf.gfile.Walk

open

mox.file.File

tf.gfile.FastGFile(tf.gfile.Gfile)

shutil.copyfile

mox.file.copy

tf.gfile.Copy

shutil.copytree

mox.file.copy_parallel

-

shutil.rmtree

mox.file.remove(..., recursive=True)

tf.gfile.DeleteRecursively