Exemple #1
0
async def request_status(ws: str,
                         work: str,
                         columns: Set[str],
                         all_cols: bool = False) -> None:
    """Request the status of an odin job over web-sockets
    :param ws: The web socket
    :param work: the job name
    :param columns: A set of columns to include in the output
    :param all_cols: Should we just show all columns, If true then columns in ignored
    """
    async with websockets.connect(ws) as websocket:
        await websocket.send(
            json.dumps({
                APIField.COMMAND: 'STATUS',
                APIField.REQUEST: work
            }))

        results = json.loads(await websocket.recv())
        if results[APIField.STATUS] == APIStatus.ERROR:
            LOGGER.error(results)
            return
        if results[APIField.STATUS] == APIStatus.OK:
            results = results[APIField.RESPONSE]
            for result in results:
                rows = [Row(**r) for r in result['task_statuses']]
                show_status(Pipeline(**result['pipeline_status']), rows,
                            columns, all_cols)
Exemple #2
0
def request_status_http(url: str, work: str, columns: Set[str], all_cols: bool = False) -> None:
    """Request the status over HTTP
    :param url: the base URL
    :param work: The pipeline ID
    :param columns: A set of columns to include in the output
    :param all_cols: Should we just show all columns, If true then columns in ignored
    """
    response = requests.get(f'{url}/v1/pipelines?q={work}')
    results = response.json()['pipelines']
    for result in results:
        rows = [_task2row(r) for r in result['tasks']]
        show_status(_result2pipe(result), rows, columns, all_cols)
Exemple #3
0
def request_status_http(url: str,
                        work: str,
                        columns: Set[str],
                        all_cols: bool = False) -> None:
    """Request the status over HTTP
    :param url: the base URL
    :param work: The pipeline ID
    :param columns: A set of columns to include in the output
    :param all_cols: Should we just show all columns, If true then columns in ignored
    """
    results = HttpClient(url).request_status(work)
    for result in results:
        rows = [_task2row(r) for r in result['tasks']]
        show_status(_result2pipe(result), rows, columns, all_cols)