kwcoco.cli.coco_move_assets module

class kwcoco.cli.coco_move_assets.CocoMoveAssetsCLI(*args, **kwargs)[source]

Bases: DataConfig

Move assets and update corresponding kwcoco files as well

Note

The options: src and dst refer to folders of asset, NOT kwcoco files. Think about this the same way you think about moving files. All kwcoco files that reference the moved assets need to be specified so they can have their paths updated. Unspecified kwcoco files may break.

This modifies the kwcoco files inplace.

This operation is not atomic and if it is interrupted then your kwcoco bundle may be put into a bad state.

Valid options: []

Parameters:
  • *args – positional arguments for this data config

  • **kwargs – keyword arguments for this data config

classmethod main(cmdline=1, **kwargs)[source]

CommandLine

xdoctest -m kwcoco.cli.coco_move_assets CocoMoveAssetsCLI.main

Example

>>> # xdoctest: +REQUIRES(module:kwutil)
>>> from kwcoco.cli.coco_move_assets import *  # NOQA
>>> import kwcoco
>>> dset = kwcoco.CocoDataset.demo('shapes8')
>>> cls = CocoMoveAssetsCLI
>>> cmdline = False
>>> kwargs = {
>>>     'coco_fpaths': [dset.fpath],
>>>     'src': ub.Path(dset.bundle_dpath) / '_assets',
>>>     'dst': ub.Path(dset.bundle_dpath) / 'new_asset_dir',
>>>     'dry': True,
>>> }
>>> cls.main(cmdline=cmdline, **kwargs)

Example

>>> # xdoctest: +SKIP
>>> # xdoctest: +REQUIRES(module:kwutil)
>>> # development use-case. TODO: turn into a real doctest
>>> cmdline = 0
>>> kwargs = dict(
>>>     coco_fpaths=['*_E.kwcoco.zip', '*_mae.kwcoco.zip'],
>>>     src='./_assets/teamfeats',
>>>     dst='./teamfeats/mae',
>>>     io_workers='avail',
>>> )
>>> cmdline = 0
>>> kwargs = dict(
>>>     coco_fpaths=['*_M.kwcoco.zip', '*_rutgers_material_seg_v4.kwcoco.zip'],
>>>     src='./_teamfeats',
>>>     dst='./teamfeats/materials',
>>>     io_workers='avail',
>>> )
>>> main(cmdline=cmdline, **kwargs)
default = {'coco_fpaths': <Value([])>, 'dry': <Value(False)>, 'dst': <Value('destination asset file or folder')>, 'io_workers': <Value(0)>, 'src': <Value('source asset file or folder')>}
class kwcoco.cli.coco_move_assets.CocoMoveAssetManager(coco_dsets, dry=False)[source]

Bases: object

submit(src, dst)[source]

Enqueue a move operation, or mark that one has already occurred.

If dst exists we assume the move has already been done, and we will update any coco files that were impacted by this, but not updated.

Otherwise we assume src needs to be moved to dst.

find_impacted()[source]
modify_datasets()[source]
move_files()[source]
dump_datasets()[source]
run()[source]
kwcoco.cli.coco_move_assets._is_relative_to_backport(self, other)[source]

A backport of is_relative_to for Python <=3.8