Tagging Archives¶
You can tag archives from the command line interface or from python.
View the source for the code samples on this page in Command Line Interface: Tagging.
Tagging on archive creation¶
When creating archives, you can specify tags using the --tag
argument. Tags must be strings and will be coerced to lowercase as a standard. You can specify as many as you would like:
$ datafs create archive1 --tag "foo" --tag "bar" --description \
> "tag test 1 has bar"
created versioned archive <DataArchive local://archive1>
$ datafs create archive2 --tag "foo" --tag "baz" --description \
> "tag test 2 has baz"
created versioned archive <DataArchive local://archive2>
You can then search for archives that have these tags using the search
command:
$ datafs search bar
archive1
$ datafs search baz
archive2
$ datafs search foo # doctest: +SKIP
archive1
archive2
Searching for multiple tags yields the set of archives that match all of the criteria:
$ datafs create archive3 --tag "foo" --tag "bar" --tag "baz" \
> --description 'tag test 3 has all the tags!'
created versioned archive <DataArchive local://archive3>
$ datafs search bar foo # doctest: +SKIP
archive1
archive3
$ datafs search bar foo baz
archive3
Searches that include a set of tags not jointly found in any archives yield no results:
$ datafs search qux
$ datafs search foo qux
Viewing and modifying tags on existing archives¶
Tags can be listed using the get_tags
command:
$ datafs get_tags archive1
foo bar
You can add tags to an archive using the add_tags
command:
$ datafs add_tags archive1 qux
$ datafs search foo qux
archive1
Removing tags from an archive¶
Specific tags can be removed from an archive using the delete_tags
command:
$ datafs delete_tags archive1 foo bar
$ datafs search foo bar
archive3