status.py 1.66 KB
Newer Older
Mark Hewitt's avatar
Mark Hewitt committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

"""Dataload status command"""

import click

17
from osducli.click_cli import CustomClickCommand, State, command_with_output
18
19
from osducli.cliclient import handle_cli_exceptions
from osducli.commands.workflow.status import status
Mark Hewitt's avatar
Mark Hewitt committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from osducli.log import get_logger

START_TIME = "startTimeStamp"
END_TIME = "endTimeStamp"
STATUS = "status"
RUN_ID = "runId"
TIME_TAKEN = "timeTaken"
FINISHED = "finished"
FAILED = "failed"

logger = get_logger(__name__)


# click entry point
34
@click.command(cls=CustomClickCommand)
Mark Hewitt's avatar
Mark Hewitt committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@click.option("-r", "--runid", help="Runid to query status of.")
@click.option(
    "-rl",
    "--runid-log",
    help="Path to a file containing run ids to get status of (see dataload ingest -h).",
    type=click.Path(exists=True, file_okay=True, readable=True, resolve_path=True),
)
@click.option(
    "-w", "--wait", help="Whether to wait for runs to complete.", is_flag=True, show_default=True
)
@handle_cli_exceptions
@command_with_output(None)
def _click_command(state: State, runid: str = None, runid_log: str = None, wait: bool = False):
    """Get status of workflow runs."""
    return status(state, runid, runid_log, wait)