當前位置: 首頁>>代碼示例>>Python>>正文


Python file_io.delete_recursively方法代碼示例

本文整理匯總了Python中tensorflow.python.lib.io.file_io.delete_recursively方法的典型用法代碼示例。如果您正苦於以下問題:Python file_io.delete_recursively方法的具體用法?Python file_io.delete_recursively怎麽用?Python file_io.delete_recursively使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.python.lib.io.file_io的用法示例。


在下文中一共展示了file_io.delete_recursively方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: GetTempDir

# 需要導入模塊: from tensorflow.python.lib.io import file_io [as 別名]
# 或者: from tensorflow.python.lib.io.file_io import delete_recursively [as 別名]
def GetTempDir():
  """Return a temporary directory for tests to use."""
  global _googletest_temp_dir
  if not _googletest_temp_dir:
    first_frame = tf_inspect.stack()[-1][0]
    temp_dir = os.path.join(tempfile.gettempdir(),
                            os.path.basename(tf_inspect.getfile(first_frame)))
    temp_dir = tempfile.mkdtemp(prefix=temp_dir.rstrip('.py'))

    def delete_temp_dir(dirname=temp_dir):
      try:
        file_io.delete_recursively(dirname)
      except errors.OpError as e:
        logging.error('Error removing %s: %s', dirname, e)

    atexit.register(delete_temp_dir)
    _googletest_temp_dir = temp_dir

  return _googletest_temp_dir 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:21,代碼來源:googletest.py

示例2: tearDownModule

# 需要導入模塊: from tensorflow.python.lib.io import file_io [as 別名]
# 或者: from tensorflow.python.lib.io.file_io import delete_recursively [as 別名]
def tearDownModule():
  file_io.delete_recursively(test.get_temp_dir()) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:4,代碼來源:saved_model_test.py

示例3: _analyze

# 需要導入模塊: from tensorflow.python.lib.io import file_io [as 別名]
# 或者: from tensorflow.python.lib.io.file_io import delete_recursively [as 別名]
def _analyze(args, cell):
  # For now, always run python2. If needed we can run python3 when the current kernel
  # is py3. Since now our transform cannot work on py3 anyway, I would rather run
  # everything with python2.
  cmd_args = ['python', 'analyze.py', '--output', _abs_path(args['output'])]
  if args['cloud']:
    cmd_args.append('--cloud')

  training_data = get_dataset_from_arg(args['data'])

  if args['cloud']:
    tmpdir = os.path.join(args['output'], 'tmp')
  else:
    tmpdir = tempfile.mkdtemp()

  try:
    if isinstance(training_data.train, datalab_ml.CsvDataSet):
      csv_data = training_data.train
      schema_file = _create_json_file(tmpdir, csv_data.schema, 'schema.json')
      for file_name in csv_data.input_files:
        cmd_args.append('--csv=' + _abs_path(file_name))
      cmd_args.extend(['--schema', schema_file])
    elif isinstance(training_data.train, datalab_ml.BigQueryDataSet):
      bq_data = training_data.train
      cmd_args.extend(['--bigquery', bq_data.table])
    else:
      raise ValueError('Unexpected training data type. Only csv or bigquery are supported.')

    features = args['features']
    features_file = _create_json_file(tmpdir, features, 'features.json')
    cmd_args.extend(['--features', features_file])

    if args['package']:
      code_path = os.path.join(tmpdir, 'package')
      _archive.extract_archive(args['package'], code_path)
    else:
      code_path = DEFAULT_PACKAGE_PATH

    _shell_process.run_and_monitor(cmd_args, os.getpid(), cwd=code_path)
  finally:
    file_io.delete_recursively(tmpdir) 
開發者ID:googledatalab,項目名稱:pydatalab,代碼行數:43,代碼來源:_ml.py

示例4: tearDownModule

# 需要導入模塊: from tensorflow.python.lib.io import file_io [as 別名]
# 或者: from tensorflow.python.lib.io.file_io import delete_recursively [as 別名]
def tearDownModule():
  file_io.delete_recursively(tf.test.get_temp_dir()) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:4,代碼來源:saved_model_test.py

示例5: create_dir_test

# 需要導入模塊: from tensorflow.python.lib.io import file_io [as 別名]
# 或者: from tensorflow.python.lib.io.file_io import delete_recursively [as 別名]
def create_dir_test():
  """Verifies file_io directory handling methods ."""

  starttime = int(round(time.time() * 1000))
  dir_name = "%s/tf_gcs_test_%s" % (FLAGS.gcs_bucket_url, starttime)
  print("Creating dir %s" % dir_name)
  file_io.create_dir(dir_name)
  elapsed = int(round(time.time() * 1000)) - starttime
  print("Created directory in: %d milliseconds" % elapsed)
  # Check that the directory exists.
  dir_exists = file_io.is_directory(dir_name)
  print("%s directory exists: %s" % (dir_name, dir_exists))

  # List contents of just created directory.
  print("Listing directory %s." % dir_name)
  starttime = int(round(time.time() * 1000))
  print(file_io.list_directory(dir_name))
  elapsed = int(round(time.time() * 1000)) - starttime
  print("Listed directory %s in %s milliseconds" % (dir_name, elapsed))

  # Delete directory.
  print("Deleting directory %s." % dir_name)
  starttime = int(round(time.time() * 1000))
  file_io.delete_recursively(dir_name)
  elapsed = int(round(time.time() * 1000)) - starttime
  print("Deleted directory %s in %s milliseconds" % (dir_name, elapsed)) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:28,代碼來源:gcs_smoke.py

示例6: create_object_test

# 需要導入模塊: from tensorflow.python.lib.io import file_io [as 別名]
# 或者: from tensorflow.python.lib.io.file_io import delete_recursively [as 別名]
def create_object_test():
  """Verifies file_io's object manipulation methods ."""
  starttime = int(round(time.time() * 1000))
  dir_name = "%s/tf_gcs_test_%s" % (FLAGS.gcs_bucket_url, starttime)
  print("Creating dir %s." % dir_name)
  file_io.create_dir(dir_name)

  # Create a file in this directory.
  file_name = "%s/test_file.txt" % dir_name
  print("Creating file %s." % file_name)
  file_io.write_string_to_file(file_name, "test file creation.")

  list_files_pattern = "%s/test_file*.txt" % dir_name
  print("Getting files matching pattern %s." % list_files_pattern)
  files_list = file_io.get_matching_files(list_files_pattern)
  print(files_list)

  assert len(files_list) == 1
  assert files_list[0] == file_name

  # Cleanup test files.
  print("Deleting file %s." % file_name)
  file_io.delete_file(file_name)

  # Delete directory.
  print("Deleting directory %s." % dir_name)
  file_io.delete_recursively(dir_name) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:29,代碼來源:gcs_smoke.py


注:本文中的tensorflow.python.lib.io.file_io.delete_recursively方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。