datafed.CLI
Module Contents
Classes
A group allows a command to have subcommands attached. This is |
|
A group allows a command to have subcommands attached. This is |
Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'datafed' is the command-line interface (CLI) for the DataFed federated data management |
|
|
|
|
|
|
|
Set/print current working collection or path. 'ID' can be a collection ID, alias, user |
|
Get current working path. Displays the full path of the current working |
|
|
|
View data record information. Displays record title, description, tags, |
|
Create a new data record. The data record 'title' is required, but all |
|
Update an existing data record. The data record ID is required and can be |
|
Delete one or more existing data records. Multiple ID arguments can be |
|
Get (download) raw data of data records and/or collections. Multiple ID |
|
Put (upload) raw data located at PATH to DataFed record ID. The ID |
|
|
|
Batch create data records from JSON file(s). Multiple FILE arguments may be |
|
Batch update data records from JSON file(s). Multiple FILE arguments may be |
|
List contents of a collection, or shared items. ID may be a collection ID |
|
|
|
View collection information. Displays collection title, description, and |
|
Create a new collection. The collection 'title' is required, but all |
|
Update an existing collection. The collection ID is required and can be |
|
Delete one or more existing collections. Multiple ID arguments can be |
|
Add data records and/or collections to a collection. COLL_ID is the |
|
Remove data records and/or collections from a collection. COLL_ID is the |
|
|
|
List saved queries. |
|
View a saved query by ID. |
|
Create a saved query. |
|
Update a saved query. The title and search terms of a query may be updated; |
|
Delete a saved query by ID. |
|
Execute a saved query by ID. |
|
Run a direct query on data or collections. The default scope is the current |
|
|
|
List all users that are collaborators. Collaborators are defined as users |
|
List all users. |
|
View user information. |
|
Show current authenticated user ID. |
|
|
|
List projects associated with current user. List projects that are owned or managed by the |
|
View project information. Current user must have a role (owner, manager, or |
|
List users and/or projects sharing data with current user. |
|
|
|
List recent tasks. If no time or status filter options are |
|
Show task information. Use the ID argument to view a specific task |
|
|
|
Get Globus endpoint for the current session. At the start of a session, the |
|
Set endpoint for the current session. If no endpoint is given, the |
|
List recently used endpoints. |
Show the default Globus endpoint. |
|
|
Set the default Globus endpoint. The default endpoint will be set from the |
|
Setup local credentials. This command installs DataFed credentials for the |
|
Set/display verbosity level. The verbosity level argument can be 0 |
|
Show DataFed CLI help. Include a command name as the argument to see |
Exit an interactive session. Ctrl-C may also be used to exit the shell. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Attributes
- datafed.CLI._OM_TEXT = 0
- datafed.CLI._OM_JSON = 1
- datafed.CLI._OM_RETN = 2
- datafed.CLI._STAT_OK = 0
- datafed.CLI._STAT_ERROR = 1
- datafed.CLI._capi
- datafed.CLI._return_val
- datafed.CLI._uid
- datafed.CLI._cur_ctx
- datafed.CLI._cur_coll
- datafed.CLI._cur_coll_prefix = 'root'
- datafed.CLI._cur_coll_title
- datafed.CLI._cur_alias_prefix = ''
- datafed.CLI._prev_coll = 'root'
- datafed.CLI._prev_ctx
- datafed.CLI._list_items = []
- datafed.CLI._interactive = True
- datafed.CLI._verbosity_sticky = 1
- datafed.CLI._verbosity = 1
- datafed.CLI._output_mode_sticky
- datafed.CLI._output_mode
- datafed.CLI._ctxt_settings
- datafed.CLI._task_statuses
- datafed.CLI._task_types
- datafed.CLI._initialized = False
- datafed.CLI._devnull
- datafed.CLI._hdr_lev_char = ['-', '-', '^', ',']
- datafed.CLI.run()
- datafed.CLI.init(opts={})
- datafed.CLI.loginByPassword(uid, password)
- datafed.CLI.loginByToken(token)
- datafed.CLI.command(command)
- class datafed.CLI._AliasedGroup(name: str | None = None, commands: Dict[str, Command] | Sequence[Command] | None = None, **attrs: Any)
Bases:
click.Group
A group allows a command to have subcommands attached. This is the most common way to implement nesting in Click.
- Parameters:
name – The name of the group command.
commands – A dict mapping names to
Command
objects. Can also be a list ofCommand
, which will useCommand.name
to create the dict.attrs – Other command arguments described in
MultiCommand
,Command
, andBaseCommand
.
Changed in version 8.0: The
commmands
argument can be a list of command objects.- get_command(ctx, cmd_name)
Given a context and a command name, this returns a
Command
object if it exists or returns None.
- resolve_command(ctx, args)
- class datafed.CLI._AliasedGroupRoot(name: str | None = None, commands: Dict[str, Command] | Sequence[Command] | None = None, **attrs: Any)
Bases:
_AliasedGroup
A group allows a command to have subcommands attached. This is the most common way to implement nesting in Click.
- Parameters:
name – The name of the group command.
commands – A dict mapping names to
Command
objects. Can also be a list ofCommand
, which will useCommand.name
to create the dict.attrs – Other command arguments described in
MultiCommand
,Command
, andBaseCommand
.
Changed in version 8.0: The
commmands
argument can be a list of command objects.- get_command(ctx, cmd_name)
Given a context and a command name, this returns a
Command
object if it exists or returns None.
- exception datafed.CLI._NoCommand(*args, **kwargs)
Bases:
Exception
Common base class for all non-exit exceptions.
- datafed.CLI._set_script_cb(ctx, param, value)
- datafed.CLI._set_verbosity_cb(ctx, param, value)
- datafed.CLI.__global_context_options
- datafed.CLI._global_context_options(func)
- datafed.CLI.__global_output_options
- datafed.CLI._global_output_options(func)
- datafed.CLI._cli(ctx, *args, **kwargs)
‘datafed’ is the command-line interface (CLI) for the DataFed federated data management service and may be used to access many of the features available via the DataFed web portal. This CLI may be used interactively (human-friendly output) or for scripting (JSON output) by specifying the -s option.
When the datafed CLI is run without any command arguments, a interactive shell session is started. While in the shell, commands should be entered without specifying the ‘datafed’ prefix.
- datafed.CLI._genDoc(ctx)
- datafed.CLI._genDocHeader(cmd, level)
- datafed.CLI._genDocCmd(cmd, ctx, level, parname=None, recurse=True)
- datafed.CLI._wc(coll_id)
Set/print current working collection or path. ‘ID’ can be a collection ID, alias, user or project ID, listing index, previous collection (‘-‘), or path (‘..’,’/’,’~’). ‘cd’ is an alias for the ‘wc’ command.
The ‘wc’ command can be used to switch to a different user or project context by either specifying a user/project ID/alias as the argument, or by specifying a collection ID/alias that is owned by another user or project. In either case, if permission is granted, the CLI context will be changed to the associated user/project and all subsequent commands will act within that context. To return to the authenticated users context, use the ‘wc ~’ command. The ‘~’ path indicates the authenticated user’s root collection; whereas the ‘/’ path is the root colelction of the current context.
- datafed.CLI._wp()
Get current working path. Displays the full path of the current working collection starting from the root collection of the associated user or project.
- datafed.CLI._data()
- datafed.CLI._dataView(data_id, context)
View data record information. Displays record title, description, tags, and other informational and administrative fields. ID may be a data record identifier, alias, or index value from a listing. By default, description text is truncated and metadata is not shown unless the verbosity is as level 2.
- datafed.CLI._dataCreate(title, alias, description, tags, raw_data_file, extension, external, metadata, metadata_file, schema, schema_enforce, parent, repository, deps, context)
Create a new data record. The data record ‘title’ is required, but all other attributes are optional. On success, the ID of the created data record is returned. Note that if a parent collection is specified, and that collection belongs to a project or other collaborator, the creating user must have permission to write to that collection. The raw-data-file option is only supported in interactive mode and is provided as a convenience to avoid a separate dataPut() call.
- datafed.CLI._dataUpdate(data_id, title, alias, description, tags, raw_data_file, extension, metadata, metadata_file, metadata_set, schema, schema_enforce, deps_add, deps_rem, context)
Update an existing data record. The data record ID is required and can be an ID, alias, or listing index; all other record attributes are optional. The raw-data-file option is only supported in interactive mode and is provided as a convenience to avoid a separate dataPut() call.
- datafed.CLI._dataDelete(data_id, force, context)
Delete one or more existing data records. Multiple ID arguments can be provided and may data record IDs, aliases, or index values from a listing. By default, a confirmation prompt is used, but this can be bypassed with the ‘–force’ option.
- datafed.CLI._dataGet(df_id, path, wait, encrypt, orig_fname, context)
Get (download) raw data of data records and/or collections. Multiple ID arguments can be specified and may be data record and/or collection IDs, aliases, or index values from s listing. The PATH argument is the destination for the download and can be either a full Globus path (with endpoint), or a local file system path (absolute or relative).
If no endpoint is specified in the PATH argument, the current endpoint will be used. If the destination PATH doesn’t exist, it will be created given sufficient filesystem permissions. Note that the path does not have to be local to where the CLI is running - data can be transferred to/from remote systems; however, full Globus paths must used in this case.
- datafed.CLI._dataPut(data_id, path, wait, extension, encrypt, context)
Put (upload) raw data located at PATH to DataFed record ID. The ID argument may be data record ID, alias, or index value from a listing. The PATH argument specifies the source file for the upload and can be either a full Globus path (with endpoint), or a local file system path (absolute or relative). If no endpoint is specified in the PATH argument, the current endpoint will be used.
- datafed.CLI._batch()
- datafed.CLI._data_batch_create(collection, file, context)
Batch create data records from JSON file(s). Multiple FILE arguments may be specified and are absolute or relative paths to JSON inputs file on a local filesystem. JSON input files may contain individual JSON objects, or arrays of JSON objects. Each JSON object represents a new data record and the JSON must comply with the DataFed record input schema (see online documentation).
- datafed.CLI._data_batch_update(file)
Batch update data records from JSON file(s). Multiple FILE arguments may be specified and are absolute or relative paths to JSON inputs file on a local filesystem. JSON input files may contain individual JSON objects, or arrays of JSON objects. Each JSON object represents a new data record and the JSON must comply with the DataFed record input schema (see online documentation).
- datafed.CLI._list(ctx, item_id, offset, count, context)
List contents of a collection, or shared items. ID may be a collection ID or alias, a path (‘..’,’/’,’~’), a user or project ID, an index value from a listing, or omitted for the current working collection. If the ID is a user or project, the ls command will list shared items associated with the given user or project.
Note: the ‘/’ path lists the root collection of the current context (user or project); whereas the ‘~’ path always lists the root collection of the authenticated user, regardless of context.
- datafed.CLI._coll()
- datafed.CLI._collView(coll_id, context)
View collection information. Displays collection title, description, and other administrative fields. ID may be a collection identifier, alias, or index value from a listing. Use ‘coll list’ command to see items contained in a collection.
- datafed.CLI._collCreate(title, alias, description, tags, topic, parent, context)
Create a new collection. The collection ‘title’ is required, but all other attributes are optional. On success, the ID of the created collection is returned. Note that if a parent collection is specified, and that collection belongs to a project or other collaborator, the creating user must have permission to write to that collection.
- datafed.CLI._collUpdate(coll_id, title, alias, description, tags, topic, context)
Update an existing collection. The collection ID is required and can be an ID, alias, or listing index; all other collection attributes are optional.
- datafed.CLI._collDelete(coll_id, force, context)
Delete one or more existing collections. Multiple ID arguments can be provided and may be collection IDs, aliases, or index values from a listing. By default, a confirmation prompt is used, but this can be bypassed with the ‘–force’ option.
When a collection is deleted, all contained collections are also deleted; however, contained data records are only deleted if they are not linked to another collection not involved in the deletion.
- datafed.CLI._collItemsAdd(coll_id, item_id, context)
Add data records and/or collections to a collection. COLL_ID is the destination collection and ITEM_IDs specify one or more data records and/or collections to add to the destination collection. COLL_ID and ITEM_IDs may be IDs, aliases, or index values from a listing. COLL_ID may also be a relative collection path (‘.’, ‘..’, or ‘/’).
- datafed.CLI._coll_rem(coll_id, item_id, context)
Remove data records and/or collections from a collection. COLL_ID is the containing collection and ITEM_IDs specify one or more data records and/or collections to remove from the containing collection. COLL_ID and ITEM_IDs may be IDs, aliases, or index values from a listing. COLL_ID may also be a relative collection path (‘.’, ‘..’, or ‘/’).
- datafed.CLI._query(*args, **kwargs)
- datafed.CLI._queryList(offset, count)
List saved queries.
- datafed.CLI._queryView(qry_id)
View a saved query by ID.
- datafed.CLI._queryCreate(title, coll_mode, coll, id, text, tag, schema, meta, meta_err, owner, creator, time_from, time_to, public, category, sort, sort_rev)
Create a saved query.
- datafed.CLI._queryUpdate(qry_id, title, coll_mode, coll, id, text, tag, schema, meta, meta_err, owner, creator, time_from, time_to, public, category, sort, sort_rev)
Update a saved query. The title and search terms of a query may be updated; however, search scope cannot currently be changed. To remove a term, specify an empty string (“”) for the associated option.
- datafed.CLI._queryDelete(qry_id)
Delete a saved query by ID.
- datafed.CLI._queryExec(qry_id, offset, count)
Execute a saved query by ID.
- datafed.CLI._queryRun(coll_mode, coll, id, text, tag, schema, meta, meta_err, owner, creator, time_from, time_to, public, category, sort, sort_rev, offset, count)
Run a direct query on data or collections. The default scope is the current authenticated user. If collections are specified, they must be in the same overall search scope. At least one search term must be specified.
The sort option ‘text’ is a text-matching relevance ranking and only works if a text term is specified in the query. The –sort-rev option does not work with text relevance matching. The sort options ‘ct’ and ‘ut’ are creation and update times, respectively.
- datafed.CLI._user()
- datafed.CLI._userListCollab(offset, count)
List all users that are collaborators. Collaborators are defined as users that have projects in common with the current user, or that have data- sharing relationships with the current user.
- datafed.CLI._userListAll(offset, count)
List all users.
- datafed.CLI._userView(uid)
View user information.
- datafed.CLI._userWho()
Show current authenticated user ID.
- datafed.CLI._project()
- datafed.CLI._projectList(owned, admin, member, offset, count)
List projects associated with current user. List projects that are owned or managed by the current user, as well as projects were the current user is a member.
- datafed.CLI._projectView(proj_id)
View project information. Current user must have a role (owner, manager, or member) within the project specified by the ID argument.
List users and/or projects sharing data with current user.
- datafed.CLI._task()
- datafed.CLI._taskList(time_from, to, since, status, offset, count)
List recent tasks. If no time or status filter options are provided, all tasks initiated by the current user are listed, most recent first. Note that the DataFed server periodically purges tasks history such that only up to 30 days of history are retained.
- datafed.CLI._taskView(task_id)
Show task information. Use the ID argument to view a specific task record, or omit to view the latest task initiated by the current user.
- datafed.CLI._ep()
- datafed.CLI._epGet()
Get Globus endpoint for the current session. At the start of a session, the current endpoint will be set to the default endpoint, if configured.
- datafed.CLI._epSet(endpoint)
Set endpoint for the current session. If no endpoint is given, the default endpoint will be set as the current endpoint, if configured.
- datafed.CLI._epList()
List recently used endpoints.
- datafed.CLI._epDefault()
- datafed.CLI._epDefaultGet()
Show the default Globus endpoint.
- datafed.CLI._epDefaultSet(current, endpoint)
Set the default Globus endpoint. The default endpoint will be set from the ‘endpoint’ argument, or if the ‘–current’ options is specified, from the currently active endpoint.
- datafed.CLI._setup(ctx)
Setup local credentials. This command installs DataFed credentials for the current user in the configured client configuration directory. Subsequent use of the DataFed CLI will read these credentials instead of requiring manual authentication.
- datafed.CLI._verbositySet(level)
Set/display verbosity level. The verbosity level argument can be 0 (lowest), 1 (normal), or 2 (highest). If the the level is omitted, the current verbosity level is returned.
- datafed.CLI._help_cli(ctx, command)
Show DataFed CLI help. Include a command name as the argument to see command-specific help.
- datafed.CLI._exit_cli()
Exit an interactive session. Ctrl-C may also be used to exit the shell.
- datafed.CLI._print_msg(level, message, err=False)
- datafed.CLI._print_ack_reply(reply=None)
- datafed.CLI._print_listing(message)
- datafed.CLI._print_user_listing(message)
- datafed.CLI._print_proj_listing(message)
- datafed.CLI._print_endpoints(message)
- datafed.CLI._print_data(message)
- datafed.CLI._print_batch(message)
- datafed.CLI._print_coll(message)
- datafed.CLI._print_deps(dr)
- datafed.CLI._print_task_listing(message)
- datafed.CLI._print_task(message)
- datafed.CLI._print_task_array(message)
- datafed.CLI._print_user(message)
- datafed.CLI._print_proj(message)
- datafed.CLI._print_path(message)
- datafed.CLI._print_query(message)
- datafed.CLI._wrap_text(text, prefix, indent, compact=False)
- datafed.CLI._resolve_id(df_id)
- datafed.CLI._resolve_coll_id(coll_id, context=None)
- datafed.CLI._generic_reply_handler(reply, printFunc)
- datafed.CLI._setWorkingCollectionTitle()
- datafed.CLI._arrayToCSV(items, skip)
- datafed.CLI._arrayToDotted(items, skip=0)
- datafed.CLI._printJSON(json, cur_indent, indent)
- datafed.CLI._printJSON_List(json, cur_indent, indent)
- datafed.CLI._bar_adaptive_human_readable(current, total, width=80)
- datafed.CLI._initialize(opts)
- datafed.CLI._addConfigOptions()