How to use the codalab.lib.bundle_cli.Commands.command function in codalab

To help you get started, we’ve selected a few codalab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codalab / codalab-worksheets / codalab / lib / bundle_cli.py View on Github external
    @Commands.command(
        'bs-ls-partitions',
        help='List available partitions (MultiDiskBundleStore only)',
        arguments=(),
    )
    def do_ls_partitions_command(self, args):
        self._fail_if_headless(args)
        self._fail_if_not_local(args)
        if not isinstance(self.manager.bundle_store(), MultiDiskBundleStore):
            print >> sys.stderr, "This command can only be run when MultiDiskBundleStore is in use."
            sys.exit(1)
        self.manager.bundle_store().ls_partitions()
github codalab / codalab-worksheets / codalab / lib / bundle_cli.py View on Github external
    @Commands.command(
        'bs-rm-partition',
        help='Remove a partition by its number (MultiDiskBundleStore only)',
        arguments=(
            Commands.Argument('partition', help='The partition you want to remove.'),
        ),
    )
    def do_rm_partition_command(self, args):
        self._fail_if_headless(args)
        self._fail_if_not_local(args)
        if not isinstance(self.manager.bundle_store(), MultiDiskBundleStore):
            print >> sys.stderr, "This command can only be run when MultiDiskBundleStore is in use."
            sys.exit(1)
        self.manager.bundle_store().rm_partition(args.partition)
github codalab / codalab-worksheets / codalab / lib / bundle_cli.py View on Github external
    @Commands.command(
        'help',
        help=[
            'Show usage information for commands.',
            '  help           : Show brief description for all commands.',
            '  help -v        : Show full usage information for all commands.',
            '  help  : Show full usage information for .',
        ],
        arguments=(
            Commands.Argument('command', help='name of command to look up', nargs='?'),
            Commands.Argument('-v', '--verbose', action='store_true', help='Display all options of all commands.'),
        ),
    )
    def do_help_command(self, args):
        self.print_version()
        if args.command:
            self.do_command([args.command, '--help'])
github codalab / codalab-worksheets / codalab / lib / bundle_cli.py View on Github external
    @Commands.command(
        'config',
        help=[
            'Set CodaLab configuration.',
            '  config          : Shows the value of .',
            '  config   : Sets  to .',
        ],
        arguments=(
            Commands.Argument('key', help='key to set (e.g., cli/verbose).'),
            Commands.Argument('value', help='Instance to bind the alias to (e.g., https://codalab.org/bundleservice).', nargs='?'),
            Commands.Argument('-r', '--remove', help='Remove this key.', action='store_true'),
        ),
    )
    def do_config_command(self, args):
        """
        Only modifies the CLI configuration, doesn't need a REST client.
        """
github codalab / codalab-worksheets / codalab / lib / bundle_cli.py View on Github external
    @Commands.command(
        'alias',
        help=[
            'Manage CodaLab instance aliases. These are mappings from names to CodaLab Worksheet servers.',
            '  alias                   : List all aliases.',
            '  alias             : Shows which instance  is bound to.',
            '  alias   : Binds  to .',
        ],
        arguments=(
            Commands.Argument('name', help='Name of the alias (e.g., main).', nargs='?'),
            Commands.Argument('instance', help='Instance to bind the alias to (e.g., https://codalab.org/bundleservice).', nargs='?'),
            Commands.Argument('-r', '--remove', help='Remove this alias.', action='store_true'),
        ),
    )
    def do_alias_command(self, args):
        """
        Show, add, modify, delete aliases (mappings from names to instances).
github codalab / codalab-worksheets / codalab / lib / bundle_cli.py View on Github external
    @Commands.command(
        'mount',
        help=[
            'Beta feature: this command may change in a future release. Mount the contents of a bundle at a read-only mountpoint.',
        ],
        arguments=(
            Commands.Argument('target_spec', help=TARGET_SPEC_FORMAT, completer=TargetsCompleter),
            Commands.Argument('--mountpoint', help='Empty directory path to set up as the mountpoint for FUSE.'),
            Commands.Argument('--verbose', help='Verbose mode for BundleFUSE.', action='store_true', default=False),
            Commands.Argument('-w', '--worksheet-spec', help='Operate on this worksheet (%s).' % WORKSHEET_SPEC_FORMAT, completer=WorksheetsCompleter),
        ),
    )
    def do_mount_command(self, args):
        if bundle_fuse.fuse_is_available:
            self._fail_if_headless(args)  # Disable on headless systems

            default_client, default_worksheet_uuid = self.parse_client_worksheet_uuid(args.worksheet_spec)
github codalab / codalab-worksheets / codalab / lib / bundle_cli.py View on Github external
    @Commands.command(
        'kill',
        help='Instruct the appropriate worker to terminate the running bundle(s).',
        arguments=(
            Commands.Argument('bundle_spec', help=BUNDLE_SPEC_FORMAT, nargs='+', completer=BundlesCompleter),
            Commands.Argument('-w', '--worksheet-spec', help='Operate on this worksheet (%s).' % WORKSHEET_SPEC_FORMAT, completer=WorksheetsCompleter),
        ),
    )
    def do_kill_command(self, args):
        args.bundle_spec = spec_util.expand_specs(args.bundle_spec)

        client, worksheet_uuid = self.parse_client_worksheet_uuid(args.worksheet_spec)
        bundle_uuids = self.resolve_bundle_uuids(client, worksheet_uuid, args.bundle_spec)
        for bundle_uuid in bundle_uuids:
            print >>self.stdout, bundle_uuid
        client.create('bundle-actions', [{
            'type': 'kill',
github codalab / codalab-worksheets / codalab / lib / bundle_cli.py View on Github external
    @Commands.command(
        'wedit',
        aliases=('we',),
        help=[
            'Edit the contents of a worksheet.',
            'See https://github.com/codalab/codalab-worksheets/wiki/User_Worksheet-Markdown for the markdown syntax.',
            '  wedit -n           : Change the name of the worksheet.',
            '  wedit -T  ...  : Set the tags of the worksheet (e.g., paper).',
            '  wedit -o       : Set the owner of the worksheet to .',
        ],
        arguments=(
            Commands.Argument('worksheet_spec', help=WORKSHEET_SPEC_FORMAT, nargs='?', completer=WorksheetsCompleter),
            Commands.Argument('-n', '--name', help='Changes the name of the worksheet (%s).' % spec_util.NAME_REGEX.pattern),
            Commands.Argument('-t', '--title', help='Change title of worksheet.'),
            Commands.Argument('-T', '--tags', help='Change tags (must appear after worksheet_spec).', nargs='*'),
            Commands.Argument('-o', '--owner-spec', help='Change owner of worksheet.'),
            Commands.Argument('--freeze', help='Freeze worksheet to prevent future modification (PERMANENT!).', action='store_true'),
github codalab / codalab-worksheets / codalab / lib / bundle_cli.py View on Github external
    @Commands.command(
        'netcat',
        help=[
            'Beta feature: this command may change in a future release. Send raw data into a port of a running bundle',
        ],
        arguments=(
            Commands.Argument('bundle_spec', help=BUNDLE_SPEC_FORMAT, completer=BundlesCompleter),
            Commands.Argument('port', type=int, help='Port'),
            Commands.Argument('message', metavar='[---] message', help='Arbitrary message to send.', completer=NullCompleter),
            Commands.Argument('--verbose', help='Verbose mode for BundleFUSE.', action='store_true', default=False),
            Commands.Argument('-w', '--worksheet-spec', help='Operate on this worksheet (%s).' % WORKSHEET_SPEC_FORMAT, completer=WorksheetsCompleter),
        ),
    )
    def do_netcat_command(self, args):
        client, worksheet_uuid = self.parse_client_worksheet_uuid(args.worksheet_spec)
        bundle_uuid = self.resolve_bundle_uuids(client, worksheet_uuid, args.bundle_spec)[0]
        info = client.netcat(bundle_uuid, port=args.port, data={"message": args.message})
github codalab / codalab-worksheets / codalab / lib / bundle_cli.py View on Github external
    @Commands.command(
        'search',
        aliases=('s',),
        help=[
            'Search for bundles on a CodaLab instance (returns 10 results by default).',
            '  search  ...  : Match name and description.',
            '  search name=             : More targeted search of using metadata fields.',
            '  search size=.sort              : Sort by a particular field.',
            '  search size=.sort-             : Sort by a particular field in reverse.',
            '  search size=.sum               : Compute total of a particular field.',
            '  search .mine                   : Match only bundles I own.',
            '  search .floating               : Match bundles that aren\'t on any worksheet.',
            '  search .count                  : Count the number of bundles.',
            '  search .limit=10               : Limit the number of results to the top 10.',
        ],
        arguments=(
            Commands.Argument('keywords', help='Keywords to search for.', nargs='+'),