Exemple #1
0
def start_preset_solution():
    parser = get_args_parser(
        'Create and start solution of verification job created on the base of specified preset.'
    )
    parser.add_argument(
        'preset',
        type=UUID,
        help=
        'Preset job identifier (uuid). Can be obtained form presets/jobs/base.json'
    )
    parser.add_argument('--replacement',
                        help='JSON file name or string with data what files '
                        'should be replaced before starting solution.')
    parser.add_argument('--rundata',
                        help='JSON file name. Set it if you would like to '
                        'start solution with specific settings.')
    args = parser.parse_args()

    cli = Cli(args.host, args.username, args.password)
    _, job_uuid = cli.create_job(args.preset)
    _, decision_uuid = cli.start_job_decision(job_uuid,
                                              rundata=args.rundata,
                                              replacement=args.replacement)

    print('Solution of verification job "{0}" was successfully started: {1}'.
          format(job_uuid, decision_uuid))
Exemple #2
0
def download_marks():
    parser = get_args_parser('Download ZIP archive of all expert marks.')
    parser.add_argument('-o', '--out', help='ZIP archive name.')
    args = parser.parse_args()

    cli = Cli(args.host, args.username, args.password)
    arch = cli.download_all_marks(args.out)

    print(
        'ZIP archive with all expert marks was successfully downloaded to "{0}"'
        .format(arch))
Exemple #3
0
def download_job():
    parser = get_args_parser('Download ZIP archive of verification job.')
    parser.add_argument('job',
                        type=UUID,
                        help='Verification job identifier (uuid).')
    parser.add_argument('-o', '--out', help='ZIP archive name.')
    args = parser.parse_args()

    cli = Cli(args.host, args.username, args.password)
    arch = cli.download_job(args.job, args.out)

    print(
        'ZIP archive with verification job "{0}" was successfully downloaded to "{1}"'
        .format(args.job, arch))
Exemple #4
0
def upload_job():
    parser = get_args_parser('Upload ZIP archive of verification job.')
    parser.add_argument('--archive', help='ZIP archive name.', required=True)
    args = parser.parse_args()

    if not os.path.exists(args.archive):
        raise FileNotFoundError(
            'ZIP archive of verification job "{0}" does not exist'.format(
                args.archive))

    cli = Cli(args.host, args.username, args.password)
    cli.upload_job(args.archive)

    print('ZIP archive of verification job "{0}" was successfully uploaded. '
          'If archive is not corrupted the job will be soon created.'.format(
              args.archive))
Exemple #5
0
def solve_job(preset_job_id, instance_ip):
    print(f'Solve {preset_job_id} job')

    cli = Cli(host=f'{instance_ip}:8998',
              username='******',
              password='******')
    decision_conf = os.path.join(os.path.dirname(__file__), 'decision.conf')

    job_id = cli.create_job(preset_job_id)[1]
    decision_id = cli.start_job_decision(job_id, rundata=decision_conf)[1]

    while True:
        time.sleep(5)
        progress = cli.decision_progress(decision_id)

        if int(progress['status']) > 2:
            break

    assert progress['status'] == '3'
Exemple #6
0
def start_solution():
    parser = get_args_parser('Start solution of verification job.')
    parser.add_argument('job',
                        type=UUID,
                        help='Verification job identifier (uuid).')
    parser.add_argument('--replacement',
                        help='JSON file name or string with data what files '
                        'should be replaced before starting solution.')
    parser.add_argument('--rundata',
                        help='JSON file name. Set it if you would like '
                        'to start solution with specific settings.')
    args = parser.parse_args()

    cli = Cli(args.host, args.username, args.password)
    _, decision_uuid = cli.start_job_decision(args.job,
                                              rundata=args.rundata,
                                              replacement=args.replacement)

    print('Solution of verification job "{0}" was successfully started: {1}'.
          format(args.job, decision_uuid))
Exemple #7
0
def download_results():
    parser = get_args_parser(
        'Download JSON file with verification results of verification job.')
    parser.add_argument('decision',
                        type=UUID,
                        help='Verification job decision identifier (uuid).')
    parser.add_argument('-o',
                        '--out',
                        help='JSON file name.',
                        default='results.json')
    args = parser.parse_args()

    cli = Cli(args.host, args.username, args.password)
    results = cli.decision_results(args.decision)

    with open(args.out, mode='w', encoding='utf-8') as fp:
        json.dump(results, fp, ensure_ascii=False, sort_keys=True, indent=4)

    print(
        'JSON file with verification results of verification job decision "{0}" was successfully downloaded to "{1}"'
        .format(args.decision, args.out))
Exemple #8
0
def update_preset_mark():
    parser = get_args_parser(
        'Update preset mark on the base of most relevant associated report and current version.'
    )
    parser.add_argument('mark', type=str, help='Preset mark path.')
    parser.add_argument('--report',
                        type=int,
                        help='Unsafe report primary key if you want '
                        'specific error trace for update.')
    args = parser.parse_args()

    cli = Cli(args.host, args.username, args.password)

    mark_path = os.path.abspath(args.mark)
    if not os.path.isfile(mark_path):
        raise ValueError('The preset mark file was not found')

    mark_identifier = UUID(os.path.splitext(os.path.basename(mark_path))[0])
    mark_data = cli.get_updated_preset_mark(mark_identifier, args.report)
    with open(mark_path, mode='w', encoding='utf-8') as fp:
        json.dump(mark_data, fp, indent=2, sort_keys=True, ensure_ascii=False)

    print('Preset mark "{0}" was successfully updated'.format(mark_identifier))