-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEVEX-2446 Add --name-mode
arg for dx find data
#1415
DEVEX-2446 Add --name-mode
arg for dx find data
#1415
Conversation
src/python/dxpy/scripts/dx.py
Outdated
@@ -6144,6 +6144,7 @@ def __call__(self, parser, namespace, values, option_string=None): | |||
parser_find_data.add_argument('--state', choices=['open', 'closing', 'closed', 'any'], help='State of the object') | |||
parser_find_data.add_argument('--visibility', choices=['hidden', 'visible', 'either'], default='visible', help='Whether the object is hidden or not') | |||
parser_find_data.add_argument('--name', help='Name of the object') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parser_find_data.add_argument('--name', help='Name of the object') | |
parser_find_data.add_argument('--name', help='Search criteria for the object name, interpreted according to the --name-mode') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help text updated for --name
src/python/dxpy/scripts/dx.py
Outdated
@@ -6144,6 +6144,7 @@ def __call__(self, parser, namespace, values, option_string=None): | |||
parser_find_data.add_argument('--state', choices=['open', 'closing', 'closed', 'any'], help='State of the object') | |||
parser_find_data.add_argument('--visibility', choices=['hidden', 'visible', 'either'], default='visible', help='Whether the object is hidden or not') | |||
parser_find_data.add_argument('--name', help='Name of the object') | |||
parser_find_data.add_argument('--name_mode', default='glob', help='Name mode to use for searching', choices=['glob', 'exact', 'regexp']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parser_find_data.add_argument('--name_mode', default='glob', help='Name mode to use for searching', choices=['glob', 'exact', 'regexp']) | |
parser_find_data.add_argument('--name-mode', default='glob', help='Name mode to use for searching', choices=['glob', 'exact', 'regexp']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switched to --name-mode
- update help text for `--name` - switch arg `--name_mode` to `--name-mode`
--name-mode
arg for dx find data
Summary
Exposes the
name_mode
parameter fordxpy.find_data_objects
called viadx find data
. This allows for setting the name mode from the hard codedglob
mode to bothregexp
andexact
.The use case for this is for wanting to find multiple patterns at once in a single
dx find data
call, which currently cannot be done. The main example is wanting to find files such as bams / vcfs and their indices, but where there are other files with the bam / vcf suffix in the same directory (e.g. having*.bam
,*.bami.bai
and*bam.recalibration_table
). This gets more diffcult with multiple file extensions to find at once.I have been using the API with
dx api system findDataObjects '{"scope":{"project": "<project>","folder":"<folder>"}, "name": {"regexp": ".*bam$|.*bai$"}, "limit": 1000}'
but this is a bit cumbersome and it would be good to be able to do it direct via the toolkit.Changes
--name_mode
argument added todx find data
subparser and passed through to thedxpy.find_data_objects
callTesting
Built toolkit locally in base python3.9-bullseye image as per readme:
Minimal example usage:
I'm not sure if there are unit tests covering this to update, but happy to add tests if needed.
Please feel free to close if not appropriate / wanted, but thought I would try contribute back before writing something more for my own workarounds.
Thanks!