MCPcopy Index your code
hub / github.com/tensorflow/datasets / copy

Method copy

tensorflow_datasets/core/github_api/github_path.py:330–352  ·  view source on GitHub ↗

Copy the current file to the given destination. Args: dst: Target file. It can be any PathLike compatible path (e.g. `gs://...`) overwrite: Whether the file should be overwritten or not Returns: The new created file. Raises: FileExistsError: If `overwrite` is f

(
      self,
      dst: epath.PathLike,
      overwrite: bool = False,
  )

Source from the content-addressed store, hash-verified

328 return self.read_bytes().decode(encoding=encoding or 'utf-8')
329
330 def copy(
331 self,
332 dst: epath.PathLike,
333 overwrite: bool = False,
334 ) -> epath.Path:
335 """Copy the current file to the given destination.
336
337 Args:
338 dst: Target file. It can be any PathLike compatible path (e.g. `gs://...`)
339 overwrite: Whether the file should be overwritten or not
340
341 Returns:
342 The new created file.
343
344 Raises:
345 FileExistsError: If `overwrite` is false and destination exists.
346 """
347 dst = epath.Path(dst)
348 if not overwrite and dst.exists():
349 raise FileExistsError(f'Cannot copy {self}. Destination {dst} exists.')
350 # Otherwise, copy src to dst
351 dst.write_bytes(self.read_bytes())
352 return dst
353
354
355def _parse_github_path(path: str) -> Tuple[str, str, str]:

Callers 11

_copyFunction · 0.45
publish_dataFunction · 0.45
__init__Method · 0.45
encode_exampleMethod · 0.45
__getstate__Method · 0.45
test_write_metadataFunction · 0.45
test_github_api_copyFunction · 0.45
download_from_sourceFunction · 0.45
__getstate__Method · 0.45
save_url_infosFunction · 0.45
_sync_file_copyMethod · 0.45

Calls 2

read_bytesMethod · 0.95
existsMethod · 0.80

Tested by 2

test_write_metadataFunction · 0.36
test_github_api_copyFunction · 0.36