Beispiel #1
0
def main(args, extra):
    '''list installed watchers
    '''
    if extra == None:
        get_watchers(args.base)
    else:
        for watcher in extra:
            list_watcher(watcher, args.base)
Beispiel #2
0
def main(args, extra):
    """list installed watchers"""
    if args.watchers is True:
        list_watcher_types()

    # Otherwise, we are listing installed watchers and tasks
    else:

        # If no watchers provided, list the watchers
        if extra is None:
            get_watchers(args.base)

        # One argument is the name of a watcher
        elif len(extra) == 1:
            list_watcher(extra[0], args.base)

        # Two arguments must be a watcher and task
        elif len(extra) == 2:
            list_task(extra[0], extra[1], args.base)

        else:
            bot.exit("Please provide none or all of <watcher> <task> to list.")
Beispiel #3
0
def main(args, extra):
    """monitor a task (from the command line), meaning wrapping it with
    multiprocessing, getting the id, and returning a result (command line
    or written to file)
    """
    # The first argument will either be part of a command, or a watcher
    watcher = args.watcher

    # The entire user command is the extra arguments
    command = extra

    # If the user provides a watcher, we are saving to it
    if watcher not in get_watchers(args.base, quiet=True):
        command = [watcher] + command
        watcher = None
    else:
        watcher = get_watcher(watcher, base=args.base, create=False)

    command = " ".join(command)
    runner = TerminalRunner(
        command,
        skip=args.skip,
        include=args.include,
        only=args.only,
        seconds=args.seconds,
    )
    runner.run()
    timepoints = runner.wait(args.func)

    # The output folder depends on the watcher func
    prefix = "decorator-psutils"
    if args.func == "gpu_task":
        prefix = "decorator-gpu"

    # If we don't have a watcher, print to terminal
    if watcher is None or args.test is True:
        print(json.dumps(timepoints))

    # Otherwise save to watcher task folder
    else:
        name = args.name
        if name is None:
            name = command.replace(" ", "-")
        name = "%s-%s" % (prefix, name)
        watcher.finish_runs({name: timepoints})
Beispiel #4
0
def main(args, extra):
    '''monitor a task (from the command line), meaning wrapping it with
       multiprocessing, getting the id, and returning a result (command line 
       or written to file)
    '''
    # The first argument will either be part of a command, or a watcher
    watcher = args.watcher

    # The entire user command is the extra arguments
    command = extra

    # If the user provides a watcher, we are saving to it
    if watcher not in get_watchers(args.base, quiet=True):
        command = [watcher] + command
        watcher = None
    else:
        watcher = get_watcher(watcher, base=args.base, create=False)

    command = ' '.join(command)
    runner = TerminalRunner(command,
                            skip=args.skip,
                            include=args.include,
                            only=args.only,
                            seconds=args.seconds)
    runner.run()
    timepoints = runner.wait()

    # If we don't have a watcher, print to terminal
    if watcher is None or args.test is True:
        print(json.dumps(timepoints))

    # Otherwise save to watcher task folder
    else:
        name = args.name
        if name is None:
            name = command.replace(' ', '-')
        name = 'decorator-psutils-%s' % name
        watcher.finish_runs({name: timepoints})
Beispiel #5
0
 def list(self, quiet=False):
     '''list the watchers. If quiet is True, don't print to the screen.'''
     watchers = get_watchers(base=self.base, quiet=quiet)
     return watchers