From 5c678b5774d4c00a8666979183495d49efec2101 Mon Sep 17 00:00:00 2001 From: "jo.perez" Date: Mon, 2 Sep 2024 13:15:59 +0200 Subject: [PATCH] feat(ml): add commands to get ml jobs This is needed to we know what exists in the CaC and in the actual platform, as it is required that jobs that are not defined in the CaC are removed. --- detection_rules/ml.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/detection_rules/ml.py b/detection_rules/ml.py index 2b06bf90f4e..dd332f3dd4e 100644 --- a/detection_rules/ml.py +++ b/detection_rules/ml.py @@ -383,6 +383,21 @@ def setup_bundle(ctx, model_tag, repo, model_dir): click.echo('To upload ML jobs, run: es experimental upload-ml-job ') +@ml_group.command('get-job') +@click.argument('job-name') +@click.pass_context +def get_job(ctx: click.Context, job_name, verbose=True): + """Remove experimental ML jobs.""" + es_client: Elasticsearch = ctx.obj['es'] + ml_client = MlClient(es_client) + + try: + jobs = ml_client.get_jobs(job_id=job_name) + except (elasticsearch.NotFoundError, elasticsearch.ConflictError) as e: + client_error(str(e), e, ctx=ctx) + click.echo(jobs) + return jobs + @ml_group.command('upload-job') @click.argument('job-file', type=click.Path(exists=True, dir_okay=False)) @click.option('--overwrite', '-o', is_flag=True, help='Overwrite job if exists by name')