Ejemplo n.º 1
0
async def ps(remote, output_format, extend, all=False, tags=[], use_ssl=False):
    "Show runs in progress, or every tracked run (--all), or with a particular tag (--tag)."
    with server(remote, use_ssl) as serv:
        with output_format(extend) as formatter:
            resp = await serv.GetRuns(RunListRequest(all=all, tags=tags))
            for run in resp.runs.runs:
                formatter(run)
Ejemplo n.º 2
0
async def load(remote, samplesheet, run_id=None, use_ssl=False):
    "Load a sample sheet to be attached to a run, or to the next run that is started."
    try:
        if '.csv' in samplesheet:
            with open(samplesheet, 'r') as file:
                ss = load_from_csv(file)
        elif '.tsv' in samplesheet or '.txt' in samplesheet:
            with open(samplesheet, 'r') as file:
                ss = load_from_csv(file, delimiter='\t')
        elif '.xls' in samplesheet:
            with open(samplesheet, 'rb') as file:
                ss = load_from_excel(file)
    except FileNotFoundError:
        click.echo(f"File '{samplesheet}' not found.")
        return 2
    except ValueError as e:
        click.echo(e, err=True)
    except ImportError:
        click.echo(f"ERROR: OpenPyXL not installed; Excel files ({samplesheet}) can't be read. Use pip to install OpenPyXL.", err=True)
    else:
        with server(*remote) as serv:
            req = RunAttachRequest(sheet=ss)
            if isinstance(run_id, int):
                req.id = run_id
            elif run_id:
                req.name = run_id
            resp = await serv.AttachSheetToRun(req)
            if resp.error:
                click.echo(resp.error.err_message, err=True)
                return 1
            else:
                click.echo(f"{samplesheet} loaded successfully.")
Ejemplo n.º 3
0
async def tag_runner(remote, run_id, tags=[], untag=False, use_ssl=False):
    with server(remote, use_ssl) as serv:
        req = RunRequest()
        if isinstance(run_id, str):
            req.name = run_id
        else:
            req.id = run_id
        resp = await serv.GetRunInfo(req)
        if resp.HasField('error'):
            click.echo(f"ERROR: {resp.error.err_message}", err=True)
            quit(1)
        else:
            run_id = resp.run.id
            return await serv.Tag(TagRequest(id=run_id, tags=tags, untag=untag))
Ejemplo n.º 4
0
async def info(remote, output_format, run_id, use_ssl=False):
    "Return information about a run, historical or in progress."
    with server(remote, use_ssl) as serv:
        with output_format(extend=True) as formatter:
            req = RunRequest()
            if isinstance(run_id, str):
                req.name = run_id
            else:
                req.id = run_id
            resp = await serv.GetRunInfo(req)
            if resp.HasField('error'):
                click.echo(f"ERROR: {resp.error.err_message}", err=True)
                quit(1)
            else:
                formatter(resp.run)
Ejemplo n.º 5
0
 async def list_run_runner(all, tags):
     with server(current_app.config['config_file']) as serv:
         return await serv.GetRuns(RunListRequest(all=True, tags=tags))
Ejemplo n.º 6
0
 async def run_getter(run_id):
     with server(current_app.config['config_file']) as serv:
         return await serv.GetRunInfo(RunRequest(id=run_id))
Ejemplo n.º 7
0
 async def attach_runner(run_id, message):
     with server(current_app.config['config_file']) as serv:
         return await serv.AttachSheetToRun(
             RunAttachRequest(name=run_id, sheet=message))
Ejemplo n.º 8
0
 async def get_run(run_id):
     config = current_app.config['config_file']
     with server(config) as serv:
         return await serv.GetRunInfo(RunRequest(id=run_id))
Ejemplo n.º 9
0
async def list_run_runner():
    config = current_app.config['config_file']
    with server(config) as serv:
        return await serv.GetRuns(RunListRequest(all=True))
Ejemplo n.º 10
0
 def test_server(self, mock_conf, mock_chan):
     from porerefiner.protocols.porerefiner.rpc.porerefiner_grpc import PoreRefinerStub
     with cli_utils.server() as serv:
         self.assertIsInstance(serv, PoreRefinerStub)
         mock_chan.assert_called()
     mock_chan.closed.assert_called()