cmem-cmemc 23.1.3__py3-none-any.whl → 23.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cmem/cmemc/cli/__init__.py +9 -3
- cmem/cmemc/cli/_cmemc.zsh +44 -0
- cmem/cmemc/cli/commands/__init__.py +3 -0
- cmem/cmemc/cli/commands/admin.py +3 -1
- cmem/cmemc/cli/commands/client.py +173 -0
- cmem/cmemc/cli/commands/config.py +1 -1
- cmem/cmemc/cli/commands/dataset.py +161 -70
- cmem/cmemc/cli/commands/graph.py +10 -10
- cmem/cmemc/cli/commands/metrics.py +3 -3
- cmem/cmemc/cli/commands/project.py +90 -27
- cmem/cmemc/cli/commands/python.py +110 -29
- cmem/cmemc/cli/commands/query.py +6 -6
- cmem/cmemc/cli/commands/resource.py +5 -5
- cmem/cmemc/cli/commands/scheduler.py +4 -4
- cmem/cmemc/cli/commands/store.py +34 -31
- cmem/cmemc/cli/commands/user.py +27 -10
- cmem/cmemc/cli/commands/variable.py +364 -0
- cmem/cmemc/cli/commands/vocabulary.py +5 -5
- cmem/cmemc/cli/commands/workflow.py +118 -55
- cmem/cmemc/cli/commands/workspace.py +5 -5
- cmem/cmemc/cli/completion.py +393 -154
- cmem/cmemc/cli/context.py +20 -3
- cmem/cmemc/cli/manual_helper/multi_page.py +11 -6
- cmem/cmemc/cli/utils.py +80 -0
- {cmem_cmemc-23.1.3.dist-info → cmem_cmemc-23.3.0.dist-info}/METADATA +6 -8
- cmem_cmemc-23.3.0.dist-info/RECORD +35 -0
- {cmem_cmemc-23.1.3.dist-info → cmem_cmemc-23.3.0.dist-info}/WHEEL +1 -1
- cmem_cmemc-23.1.3.dist-info/RECORD +0 -32
- {cmem_cmemc-23.1.3.dist-info → cmem_cmemc-23.3.0.dist-info}/LICENSE +0 -0
- {cmem_cmemc-23.1.3.dist-info → cmem_cmemc-23.3.0.dist-info}/entry_points.txt +0 -0
cmem/cmemc/cli/commands/graph.py
CHANGED
|
@@ -371,7 +371,7 @@ def _prepare_tree_output_id_only(iris, graphs):
|
|
|
371
371
|
"iris",
|
|
372
372
|
nargs=-1,
|
|
373
373
|
type=click.STRING,
|
|
374
|
-
|
|
374
|
+
shell_complete=completion.graph_uris
|
|
375
375
|
)
|
|
376
376
|
@click.pass_obj
|
|
377
377
|
def tree_command(app, all_, raw, id_only, iris):
|
|
@@ -456,7 +456,7 @@ def tree_command(app, all_, raw, id_only, iris):
|
|
|
456
456
|
click.Choice(["access", 'imported-by']),
|
|
457
457
|
str
|
|
458
458
|
]),
|
|
459
|
-
|
|
459
|
+
shell_complete=completion.graph_list_filter,
|
|
460
460
|
default=[None] * 2,
|
|
461
461
|
help="Filter graphs based on effective access conditions or import "
|
|
462
462
|
"closure. "
|
|
@@ -535,7 +535,7 @@ def list_command(app, raw, id_only, filter_):
|
|
|
535
535
|
),
|
|
536
536
|
default="-",
|
|
537
537
|
show_default=True,
|
|
538
|
-
|
|
538
|
+
shell_complete=completion.triple_files,
|
|
539
539
|
help="Export to this file."
|
|
540
540
|
)
|
|
541
541
|
@click.option(
|
|
@@ -543,7 +543,7 @@ def list_command(app, raw, id_only, filter_):
|
|
|
543
543
|
default="{{hash}}",
|
|
544
544
|
show_default=True,
|
|
545
545
|
type=click.STRING,
|
|
546
|
-
|
|
546
|
+
shell_complete=completion.graph_export_templates,
|
|
547
547
|
help="Template for the export file name(s). "
|
|
548
548
|
"Used together with --output-dir. "
|
|
549
549
|
"Possible placeholders are (Jinja2): "
|
|
@@ -565,7 +565,7 @@ def list_command(app, raw, id_only, filter_):
|
|
|
565
565
|
"iris",
|
|
566
566
|
nargs=-1,
|
|
567
567
|
type=click.STRING,
|
|
568
|
-
|
|
568
|
+
shell_complete=completion.graph_uris
|
|
569
569
|
)
|
|
570
570
|
@click.pass_obj
|
|
571
571
|
def export_command(
|
|
@@ -660,7 +660,7 @@ def export_command(
|
|
|
660
660
|
@click.argument(
|
|
661
661
|
"input_path",
|
|
662
662
|
required=True,
|
|
663
|
-
|
|
663
|
+
shell_complete=completion.triple_files,
|
|
664
664
|
type=click.Path(
|
|
665
665
|
allow_dash=False,
|
|
666
666
|
readable=True
|
|
@@ -670,7 +670,7 @@ def export_command(
|
|
|
670
670
|
"iri",
|
|
671
671
|
type=click.STRING,
|
|
672
672
|
required=False,
|
|
673
|
-
|
|
673
|
+
shell_complete=completion.graph_uris
|
|
674
674
|
)
|
|
675
675
|
@click.pass_obj
|
|
676
676
|
def import_command(app, input_path, replace, skip_existing, iri: tuple[str, ...]):
|
|
@@ -752,7 +752,7 @@ def import_command(app, input_path, replace, skip_existing, iri: tuple[str, ...]
|
|
|
752
752
|
"iris",
|
|
753
753
|
nargs=-1,
|
|
754
754
|
type=click.STRING,
|
|
755
|
-
|
|
755
|
+
shell_complete=completion.writable_graph_uris
|
|
756
756
|
)
|
|
757
757
|
@click.pass_obj
|
|
758
758
|
def delete_command(app, all_, include_imports, iris: tuple[str, ...]):
|
|
@@ -782,7 +782,7 @@ def delete_command(app, all_, include_imports, iris: tuple[str, ...]):
|
|
|
782
782
|
@click.argument(
|
|
783
783
|
"iri",
|
|
784
784
|
type=click.STRING,
|
|
785
|
-
|
|
785
|
+
shell_complete=completion.graph_uris
|
|
786
786
|
)
|
|
787
787
|
@click.pass_obj
|
|
788
788
|
def open_command(app, iri):
|
|
@@ -807,7 +807,7 @@ def open_command(app, iri):
|
|
|
807
807
|
"iris",
|
|
808
808
|
nargs=-1,
|
|
809
809
|
type=click.STRING,
|
|
810
|
-
|
|
810
|
+
shell_complete=completion.graph_uris
|
|
811
811
|
)
|
|
812
812
|
@click.pass_obj
|
|
813
813
|
def count_command(app, all_, summarize, iris: tuple[str, ...]):
|
|
@@ -49,7 +49,7 @@ def _filter_samples(family: Metric, label_filter: Tuple[Tuple[str, str], ...]) -
|
|
|
49
49
|
"metric_id",
|
|
50
50
|
required=True,
|
|
51
51
|
type=click.STRING,
|
|
52
|
-
|
|
52
|
+
shell_complete=completion.metric_ids
|
|
53
53
|
)
|
|
54
54
|
@click.option(
|
|
55
55
|
"--job", "job_id",
|
|
@@ -61,7 +61,7 @@ def _filter_samples(family: Metric, label_filter: Tuple[Tuple[str, str], ...]) -
|
|
|
61
61
|
@click.option(
|
|
62
62
|
"--filter", "label_filter",
|
|
63
63
|
type=(str, str),
|
|
64
|
-
|
|
64
|
+
shell_complete=completion.metric_label_filter,
|
|
65
65
|
multiple=True,
|
|
66
66
|
help="A set of label name/value pairs in order to filter the samples "
|
|
67
67
|
"of the requested metric family. Each metric has a different set "
|
|
@@ -137,7 +137,7 @@ def get_command(app, metric_id, job_id, label_filter, raw, enforce_table):
|
|
|
137
137
|
"metric_id",
|
|
138
138
|
required=True,
|
|
139
139
|
type=click.STRING,
|
|
140
|
-
|
|
140
|
+
shell_complete=completion.metric_ids
|
|
141
141
|
)
|
|
142
142
|
@click.option(
|
|
143
143
|
"--job", "job_id",
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"""DataIntegration project commands for the cmem command line interface."""
|
|
2
2
|
import os
|
|
3
|
-
from pathlib import Path
|
|
4
3
|
import shutil
|
|
5
4
|
import tempfile
|
|
5
|
+
from pathlib import Path
|
|
6
6
|
from zipfile import ZipFile
|
|
7
|
-
|
|
8
7
|
import click
|
|
9
|
-
|
|
8
|
+
from click import UsageError
|
|
10
9
|
from jinja2 import Template
|
|
11
10
|
|
|
12
11
|
from cmem.cmemc.cli import completion
|
|
@@ -14,20 +13,23 @@ from cmem.cmemc.cli.commands import CmemcCommand, CmemcGroup
|
|
|
14
13
|
from cmem.cmempy.config import get_di_api_endpoint
|
|
15
14
|
from cmem.cmempy.plugins.marshalling import (
|
|
16
15
|
get_extension_by_plugin,
|
|
17
|
-
get_marshalling_plugins
|
|
16
|
+
get_marshalling_plugins,
|
|
18
17
|
)
|
|
19
18
|
from cmem.cmempy.workspace.projects.export_ import export_project
|
|
20
19
|
from cmem.cmempy.workspace.projects.import_ import (
|
|
21
20
|
import_from_upload_start,
|
|
22
21
|
import_from_upload_status,
|
|
23
|
-
upload_project
|
|
22
|
+
upload_project,
|
|
24
23
|
)
|
|
25
24
|
from cmem.cmempy.workspace.projects.project import (
|
|
26
25
|
delete_project,
|
|
27
26
|
get_failed_tasks_report,
|
|
28
27
|
get_projects,
|
|
29
|
-
|
|
28
|
+
reload_project,
|
|
29
|
+
create_project_with_transformation,
|
|
30
|
+
make_new_project_with_metadata
|
|
30
31
|
)
|
|
32
|
+
from cmem.cmemc.cli.commands.variable import variable
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
def _show_type_list(app):
|
|
@@ -62,7 +64,7 @@ def _show_type_list(app):
|
|
|
62
64
|
nargs=-1,
|
|
63
65
|
required=True,
|
|
64
66
|
type=click.STRING,
|
|
65
|
-
|
|
67
|
+
shell_complete=completion.project_ids
|
|
66
68
|
)
|
|
67
69
|
@click.pass_obj
|
|
68
70
|
def open_command(app, project_ids):
|
|
@@ -136,7 +138,7 @@ def list_command(app, raw, id_only):
|
|
|
136
138
|
"project_ids",
|
|
137
139
|
nargs=-1,
|
|
138
140
|
type=click.STRING,
|
|
139
|
-
|
|
141
|
+
shell_complete=completion.project_ids
|
|
140
142
|
)
|
|
141
143
|
@click.pass_obj
|
|
142
144
|
def delete_command(app, all_, project_ids):
|
|
@@ -179,14 +181,32 @@ def delete_command(app, all_, project_ids):
|
|
|
179
181
|
|
|
180
182
|
|
|
181
183
|
@click.command(cls=CmemcCommand, name="create")
|
|
182
|
-
@click.argument(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
@click.argument("project_ids", nargs=-1, required=True, type=click.STRING)
|
|
185
|
+
@click.option(
|
|
186
|
+
"--from-transformation",
|
|
187
|
+
nargs=1,
|
|
188
|
+
shell_complete=completion.transformation_task_ids,
|
|
189
|
+
required=False,
|
|
190
|
+
help=(
|
|
191
|
+
"This option can be used to explicitly create the link specification, "
|
|
192
|
+
"which is internally executed when using the mapping suggestion of "
|
|
193
|
+
"a transformation task. You need the task ID of the transformation task."
|
|
194
|
+
),
|
|
195
|
+
)
|
|
196
|
+
@click.option(
|
|
197
|
+
"--label", "labels",
|
|
198
|
+
multiple=True,
|
|
199
|
+
help="Give the label of the project. You can give more than one label if you"
|
|
200
|
+
" create more than one project."
|
|
201
|
+
)
|
|
202
|
+
@click.option(
|
|
203
|
+
"--description", "descriptions",
|
|
204
|
+
multiple=True,
|
|
205
|
+
help="Give the description of the project. You can give more than one description"
|
|
206
|
+
" if you create more than one project."
|
|
187
207
|
)
|
|
188
208
|
@click.pass_obj
|
|
189
|
-
def create_command(app, project_ids):
|
|
209
|
+
def create_command(app, project_ids, from_transformation, labels, descriptions):
|
|
190
210
|
"""Create projects.
|
|
191
211
|
|
|
192
212
|
This command creates one or more new projects.
|
|
@@ -194,24 +214,66 @@ def create_command(app, project_ids):
|
|
|
194
214
|
|
|
195
215
|
Note: Projects can be listed by using the `project list` command.
|
|
196
216
|
"""
|
|
197
|
-
|
|
198
|
-
|
|
217
|
+
if from_transformation and len(project_ids) > 1:
|
|
218
|
+
raise ValueError(
|
|
219
|
+
"By using --from-transformation,"
|
|
220
|
+
" the project ID parameter is limited to a single project ID."
|
|
221
|
+
)
|
|
199
222
|
|
|
200
223
|
all_projects = get_projects()
|
|
201
|
-
# test if one of the created projects already exist
|
|
202
224
|
for project_id in project_ids:
|
|
203
|
-
if project_id in
|
|
204
|
-
raise ValueError(f"Project {project_id} already
|
|
225
|
+
if project_id in [project["name"] for project in all_projects]:
|
|
226
|
+
raise ValueError(f"Project {project_id} already exists.")
|
|
227
|
+
|
|
228
|
+
if from_transformation:
|
|
229
|
+
transformation_parts = from_transformation.split(":")
|
|
230
|
+
transformation_project, transformation_task_id = (
|
|
231
|
+
transformation_parts[0],
|
|
232
|
+
transformation_parts[1],
|
|
233
|
+
)
|
|
234
|
+
app.echo_info(
|
|
235
|
+
f"Create new project {project_ids[0]} from transformation"
|
|
236
|
+
f" {transformation_task_id} ... ", nl=False
|
|
237
|
+
)
|
|
238
|
+
create_project_with_transformation(
|
|
239
|
+
transform_project_id=transformation_project,
|
|
240
|
+
transform_task_id=transformation_task_id,
|
|
241
|
+
matching_link_spec_project_id=project_ids[0],
|
|
242
|
+
matching_link_spec_id=f"linking_{transformation_task_id.split('_')[-1]}"
|
|
243
|
+
)
|
|
244
|
+
app.echo_success("done")
|
|
245
|
+
return
|
|
205
246
|
|
|
206
247
|
count = len(project_ids)
|
|
207
248
|
current = 1
|
|
249
|
+
if len(labels) > 0 and len(labels) != count:
|
|
250
|
+
raise UsageError(
|
|
251
|
+
"Either give labels for all projects or for no project."
|
|
252
|
+
f" Got {len(labels)} labels but {count} projects."
|
|
253
|
+
)
|
|
254
|
+
if len(descriptions) > 0 and len(descriptions) != count:
|
|
255
|
+
raise UsageError(
|
|
256
|
+
"Either give descriptions for all projects or for no project."
|
|
257
|
+
f" Got {len(descriptions)} descriptions but {count} projects."
|
|
258
|
+
)
|
|
259
|
+
|
|
208
260
|
for project_id in project_ids:
|
|
261
|
+
try:
|
|
262
|
+
label = labels[current - 1]
|
|
263
|
+
except IndexError:
|
|
264
|
+
label = project_id
|
|
265
|
+
try:
|
|
266
|
+
description = descriptions[current - 1]
|
|
267
|
+
except IndexError:
|
|
268
|
+
description = ""
|
|
209
269
|
app.echo_info(
|
|
210
270
|
f"Create new project {current}/{count}: {project_id} ... ",
|
|
211
271
|
nl=False
|
|
212
272
|
)
|
|
213
273
|
app.echo_debug(get_projects())
|
|
214
|
-
|
|
274
|
+
make_new_project_with_metadata(
|
|
275
|
+
project_id, label=label, description=description
|
|
276
|
+
)
|
|
215
277
|
app.echo_success("done")
|
|
216
278
|
current = current + 1
|
|
217
279
|
|
|
@@ -237,7 +299,7 @@ def create_command(app, project_ids):
|
|
|
237
299
|
writable=True,
|
|
238
300
|
file_okay=False
|
|
239
301
|
),
|
|
240
|
-
#
|
|
302
|
+
# shell_complete=directories,
|
|
241
303
|
help="The base directory, where the project files will be created. "
|
|
242
304
|
"If this directory does not exist, it will be silently created."
|
|
243
305
|
)
|
|
@@ -246,7 +308,7 @@ def create_command(app, project_ids):
|
|
|
246
308
|
default="xmlZip",
|
|
247
309
|
show_default=True,
|
|
248
310
|
type=click.STRING,
|
|
249
|
-
|
|
311
|
+
shell_complete=completion.marshalling_plugins,
|
|
250
312
|
help="Type of the exported project file(s). Use the --help-types option "
|
|
251
313
|
"or tab completion to see a list of possible types."
|
|
252
314
|
)
|
|
@@ -255,7 +317,7 @@ def create_command(app, project_ids):
|
|
|
255
317
|
default="{{date}}-{{connection}}-{{id}}.project",
|
|
256
318
|
show_default=True,
|
|
257
319
|
type=click.STRING,
|
|
258
|
-
|
|
320
|
+
shell_complete=completion.project_export_templates,
|
|
259
321
|
help="Template for the export file name(s). "
|
|
260
322
|
"Possible placeholders are (Jinja2): "
|
|
261
323
|
"{{id}} (the project ID), "
|
|
@@ -282,7 +344,7 @@ def create_command(app, project_ids):
|
|
|
282
344
|
"project_ids",
|
|
283
345
|
nargs=-1,
|
|
284
346
|
type=click.STRING,
|
|
285
|
-
|
|
347
|
+
shell_complete=completion.project_ids
|
|
286
348
|
)
|
|
287
349
|
@click.pass_obj
|
|
288
350
|
def export_command(
|
|
@@ -381,7 +443,7 @@ def export_command(
|
|
|
381
443
|
@click.command(cls=CmemcCommand, name="import")
|
|
382
444
|
@click.argument(
|
|
383
445
|
"path",
|
|
384
|
-
|
|
446
|
+
shell_complete=completion.project_files,
|
|
385
447
|
type=click.Path(
|
|
386
448
|
allow_dash=False,
|
|
387
449
|
dir_okay=True,
|
|
@@ -394,7 +456,7 @@ def export_command(
|
|
|
394
456
|
type=click.STRING,
|
|
395
457
|
required=False,
|
|
396
458
|
default='',
|
|
397
|
-
|
|
459
|
+
shell_complete=completion.project_ids
|
|
398
460
|
)
|
|
399
461
|
@click.option(
|
|
400
462
|
"-o", "--overwrite",
|
|
@@ -491,7 +553,7 @@ def import_command(app, path, project_id, overwrite):
|
|
|
491
553
|
"project_ids",
|
|
492
554
|
nargs=-1,
|
|
493
555
|
type=click.STRING,
|
|
494
|
-
|
|
556
|
+
shell_complete=completion.project_ids
|
|
495
557
|
)
|
|
496
558
|
@click.pass_obj
|
|
497
559
|
def reload_command(app, all_, project_ids):
|
|
@@ -556,3 +618,4 @@ project.add_command(import_command)
|
|
|
556
618
|
project.add_command(delete_command)
|
|
557
619
|
project.add_command(create_command)
|
|
558
620
|
project.add_command(reload_command)
|
|
621
|
+
project.add_command(variable)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"""DataIntegration python management commands."""
|
|
2
2
|
import sys
|
|
3
|
+
from dataclasses import asdict
|
|
3
4
|
from re import match
|
|
4
5
|
|
|
5
6
|
import click
|
|
7
|
+
from click import UsageError
|
|
6
8
|
|
|
7
9
|
from cmem.cmemc.cli import completion
|
|
8
10
|
from cmem.cmemc.cli.commands import CmemcCommand, CmemcGroup
|
|
@@ -12,6 +14,7 @@ from cmem.cmempy.workspace.python import (
|
|
|
12
14
|
list_packages, list_plugins,
|
|
13
15
|
uninstall_package, update_plugins
|
|
14
16
|
)
|
|
17
|
+
from cmem.cmemc.cli.utils import get_published_packages
|
|
15
18
|
|
|
16
19
|
|
|
17
20
|
def _get_package_id(module_name: str) -> str:
|
|
@@ -29,7 +32,7 @@ def _looks_like_a_package(package: str) -> bool:
|
|
|
29
32
|
@click.command(cls=CmemcCommand, name="install")
|
|
30
33
|
@click.argument(
|
|
31
34
|
"PACKAGE",
|
|
32
|
-
|
|
35
|
+
shell_complete=completion.installable_packages,
|
|
33
36
|
type=click.Path(
|
|
34
37
|
readable=True,
|
|
35
38
|
allow_dash=False,
|
|
@@ -79,34 +82,58 @@ def install_command(app: ApplicationContext, package):
|
|
|
79
82
|
@click.command(cls=CmemcCommand, name="uninstall")
|
|
80
83
|
@click.argument(
|
|
81
84
|
"PACKAGE_NAME",
|
|
82
|
-
|
|
85
|
+
nargs=-1,
|
|
86
|
+
shell_complete=completion.installed_package_names
|
|
87
|
+
)
|
|
88
|
+
@click.option(
|
|
89
|
+
"-a", "--all", "all_",
|
|
90
|
+
is_flag=True,
|
|
91
|
+
help="This option removes all installed packages from the system,"
|
|
92
|
+
" leaving only the pre-installed mandatory packages in the environment."
|
|
83
93
|
)
|
|
84
94
|
@click.pass_obj
|
|
85
|
-
def uninstall_command(app: ApplicationContext, package_name):
|
|
86
|
-
"""Uninstall a python
|
|
95
|
+
def uninstall_command(app: ApplicationContext, package_name, all_):
|
|
96
|
+
"""Uninstall a python packages from the workspace.
|
|
87
97
|
|
|
88
98
|
This command is essentially a `pip uninstall` in the remote
|
|
89
99
|
python environment.
|
|
90
100
|
"""
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
if all_:
|
|
102
|
+
app.echo_info(
|
|
103
|
+
"Wiping Python environment ... ",
|
|
104
|
+
nl=False
|
|
105
|
+
)
|
|
106
|
+
response = uninstall_package(package_name="--all")
|
|
107
|
+
app.echo_success("done")
|
|
108
|
+
app.echo_debug("Updated Plugins: " + str(update_plugins()))
|
|
109
|
+
return
|
|
110
|
+
|
|
111
|
+
if not package_name:
|
|
112
|
+
raise UsageError(
|
|
113
|
+
"Either give at least one package name or wipe the whole python"
|
|
114
|
+
" environment with the '--all' option."
|
|
115
|
+
)
|
|
95
116
|
packages = list_packages()
|
|
96
117
|
app.echo_debug(packages)
|
|
97
|
-
|
|
98
|
-
app.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
for _ in package_name:
|
|
119
|
+
app.echo_info(
|
|
120
|
+
f"Uninstall package {_} ... ",
|
|
121
|
+
nl=False
|
|
122
|
+
)
|
|
123
|
+
if _ not in [package["name"] for package in packages]:
|
|
124
|
+
app.echo_error("not installed")
|
|
125
|
+
app.echo_debug("Updated Plugins: " + str(update_plugins()))
|
|
126
|
+
sys.exit(1)
|
|
127
|
+
response = uninstall_package(package_name=_)
|
|
128
|
+
for output_line in response["standardOutput"].splitlines():
|
|
129
|
+
app.echo_debug(output_line)
|
|
130
|
+
if response["success"]:
|
|
131
|
+
app.echo_success("done")
|
|
132
|
+
if len(response["errorOutput"].strip()) > 0:
|
|
133
|
+
app.echo_warning(response["errorOutput"])
|
|
134
|
+
else:
|
|
135
|
+
app.echo_error("error")
|
|
136
|
+
app.echo_debug(response.content.decode())
|
|
110
137
|
app.echo_debug("Updated Plugins: " + str(update_plugins()))
|
|
111
138
|
|
|
112
139
|
|
|
@@ -122,30 +149,65 @@ def uninstall_command(app: ApplicationContext, package_name):
|
|
|
122
149
|
help="Lists only package identifier. "
|
|
123
150
|
"This is useful for piping the IDs into other commands."
|
|
124
151
|
)
|
|
152
|
+
@click.option(
|
|
153
|
+
"--available",
|
|
154
|
+
is_flag=True,
|
|
155
|
+
help="Instead of listing installed packages, this option lists installable packages"
|
|
156
|
+
" from pypi.org, which are prefixed with 'cmem-plugin-' and so are most likely"
|
|
157
|
+
" Corporate Memory plugin packages."
|
|
158
|
+
)
|
|
125
159
|
@click.pass_obj
|
|
126
|
-
def list_command(app: ApplicationContext, raw, id_only):
|
|
160
|
+
def list_command(app: ApplicationContext, raw, id_only, available):
|
|
127
161
|
"""List installed python packages.
|
|
128
162
|
|
|
129
163
|
This command is essentially a `pip list` in the remote python environment.
|
|
130
164
|
|
|
131
165
|
It outputs a table of python package identifiers with version information.
|
|
132
166
|
"""
|
|
133
|
-
|
|
167
|
+
if available:
|
|
168
|
+
published_packages = get_published_packages()
|
|
169
|
+
|
|
170
|
+
if raw:
|
|
171
|
+
app.echo_info_json(
|
|
172
|
+
[asdict(_) for _ in published_packages]
|
|
173
|
+
)
|
|
174
|
+
return
|
|
175
|
+
|
|
176
|
+
if id_only:
|
|
177
|
+
for _ in published_packages:
|
|
178
|
+
app.echo_info(_.name)
|
|
179
|
+
return
|
|
180
|
+
|
|
181
|
+
table_published = []
|
|
182
|
+
for _ in published_packages:
|
|
183
|
+
table_published.append(
|
|
184
|
+
(_.name, _.version, str(_.published)[:10], _.description)
|
|
185
|
+
)
|
|
186
|
+
app.echo_info_table(
|
|
187
|
+
table_published,
|
|
188
|
+
headers=["Name", "Version", "Published", "Description"],
|
|
189
|
+
sort_column=0
|
|
190
|
+
)
|
|
191
|
+
return
|
|
192
|
+
|
|
193
|
+
installed_packages = list_packages()
|
|
134
194
|
if raw:
|
|
135
|
-
app.echo_info_json(
|
|
195
|
+
app.echo_info_json(installed_packages)
|
|
136
196
|
return
|
|
197
|
+
|
|
137
198
|
if id_only:
|
|
138
|
-
for package in
|
|
199
|
+
for package in installed_packages:
|
|
139
200
|
app.echo_info(package["name"])
|
|
140
201
|
return
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
202
|
+
|
|
203
|
+
table_installed = []
|
|
204
|
+
for package in installed_packages:
|
|
205
|
+
table_installed.append((
|
|
144
206
|
package["name"],
|
|
145
207
|
package["version"]
|
|
146
208
|
))
|
|
147
209
|
app.echo_info_table(
|
|
148
|
-
|
|
210
|
+
table_installed,
|
|
149
211
|
headers=["Name", "Version"],
|
|
150
212
|
sort_column=0
|
|
151
213
|
)
|
|
@@ -215,6 +277,24 @@ def list_plugins_command(
|
|
|
215
277
|
app.echo_error(raw_output["error"])
|
|
216
278
|
|
|
217
279
|
|
|
280
|
+
@click.command(cls=CmemcCommand, name="open")
|
|
281
|
+
@click.argument(
|
|
282
|
+
"PACKAGE",
|
|
283
|
+
shell_complete=completion.published_package_names,
|
|
284
|
+
)
|
|
285
|
+
@click.pass_obj
|
|
286
|
+
def open_command(app: ApplicationContext, package):
|
|
287
|
+
"""Open a package pypi.org page in the browser.
|
|
288
|
+
|
|
289
|
+
With this command, you can open the pypi.org page of a published package in your
|
|
290
|
+
browser. From there, you can follow links, review the version history as well
|
|
291
|
+
as the origin of the package, and read the provided documentation.
|
|
292
|
+
"""
|
|
293
|
+
full_url = f"https://pypi.org/project/{package}/"
|
|
294
|
+
app.echo_debug(f"Open {package}: {full_url}")
|
|
295
|
+
click.launch(full_url)
|
|
296
|
+
|
|
297
|
+
|
|
218
298
|
@click.group(cls=CmemcGroup)
|
|
219
299
|
def python():
|
|
220
300
|
"""List, install, or uninstall python packages.
|
|
@@ -232,3 +312,4 @@ python.add_command(install_command)
|
|
|
232
312
|
python.add_command(uninstall_command)
|
|
233
313
|
python.add_command(list_command)
|
|
234
314
|
python.add_command(list_plugins_command)
|
|
315
|
+
python.add_command(open_command)
|
cmem/cmemc/cli/commands/query.py
CHANGED
|
@@ -452,7 +452,7 @@ def list_command(app, id_only):
|
|
|
452
452
|
"QUERIES",
|
|
453
453
|
nargs=-1,
|
|
454
454
|
required=True,
|
|
455
|
-
|
|
455
|
+
shell_complete=completion.remote_queries_and_sparql_files
|
|
456
456
|
)
|
|
457
457
|
@click.option(
|
|
458
458
|
"--accept",
|
|
@@ -482,7 +482,7 @@ def list_command(app, id_only):
|
|
|
482
482
|
@click.option(
|
|
483
483
|
"--parameter", "-p",
|
|
484
484
|
type=(str, str),
|
|
485
|
-
|
|
485
|
+
shell_complete=completion.placeholder,
|
|
486
486
|
multiple=True,
|
|
487
487
|
help="In case of a parameterized query (placeholders with the '{{key}}' "
|
|
488
488
|
"syntax), this option fills all placeholder with a given value "
|
|
@@ -582,7 +582,7 @@ def execute_command(
|
|
|
582
582
|
"QUERIES",
|
|
583
583
|
nargs=-1,
|
|
584
584
|
required=True,
|
|
585
|
-
|
|
585
|
+
shell_complete=completion.remote_queries_and_sparql_files
|
|
586
586
|
)
|
|
587
587
|
@click.pass_obj
|
|
588
588
|
def open_command(app, queries):
|
|
@@ -623,7 +623,7 @@ def open_command(app, queries):
|
|
|
623
623
|
"--filter", "filter_",
|
|
624
624
|
type=(str, str),
|
|
625
625
|
multiple=True,
|
|
626
|
-
|
|
626
|
+
shell_complete=completion.query_status_filter,
|
|
627
627
|
help=QUERY_FILTER_HELP_TEXT,
|
|
628
628
|
)
|
|
629
629
|
@click.argument(
|
|
@@ -685,7 +685,7 @@ def status_command(app, id_only, raw, filter_, query_uuid):
|
|
|
685
685
|
@click.argument(
|
|
686
686
|
"REPLAY_FILE",
|
|
687
687
|
required=True,
|
|
688
|
-
|
|
688
|
+
shell_complete=completion.replay_files,
|
|
689
689
|
type=click.Path(
|
|
690
690
|
exists=True,
|
|
691
691
|
allow_dash=False,
|
|
@@ -717,7 +717,7 @@ def status_command(app, id_only, raw, filter_, query_uuid):
|
|
|
717
717
|
@click.option(
|
|
718
718
|
"--output-file",
|
|
719
719
|
required=False,
|
|
720
|
-
|
|
720
|
+
shell_complete=completion.replay_files,
|
|
721
721
|
help="Save the optional output to this file. Input and output of the "
|
|
722
722
|
"command can be the same file. The output is written at the end "
|
|
723
723
|
"of a successful command execution. The output can be stdout "
|
|
@@ -61,7 +61,7 @@ def _get_resources_filtered(resources, filter_name, filter_value):
|
|
|
61
61
|
"--filter", "filters_",
|
|
62
62
|
multiple=True,
|
|
63
63
|
type=(str, str),
|
|
64
|
-
|
|
64
|
+
shell_complete=completion.resource_list_filter,
|
|
65
65
|
help=RESOURCE_FILTER_TEXT
|
|
66
66
|
)
|
|
67
67
|
@click.pass_obj
|
|
@@ -101,7 +101,7 @@ def list_command(app, raw, id_only, filters_):
|
|
|
101
101
|
"resource_ids",
|
|
102
102
|
nargs=-1,
|
|
103
103
|
type=click.STRING,
|
|
104
|
-
|
|
104
|
+
shell_complete=completion.resource_ids
|
|
105
105
|
)
|
|
106
106
|
@click.option(
|
|
107
107
|
"--force",
|
|
@@ -118,7 +118,7 @@ def list_command(app, raw, id_only, filters_):
|
|
|
118
118
|
"--filter", "filters_",
|
|
119
119
|
multiple=True,
|
|
120
120
|
type=(str, str),
|
|
121
|
-
|
|
121
|
+
shell_complete=completion.resource_list_filter,
|
|
122
122
|
help=RESOURCE_FILTER_TEXT
|
|
123
123
|
)
|
|
124
124
|
@click.pass_obj
|
|
@@ -184,7 +184,7 @@ def delete_command(app, resource_ids, force, all_, filters_):
|
|
|
184
184
|
@click.argument(
|
|
185
185
|
"resource_id",
|
|
186
186
|
type=click.STRING,
|
|
187
|
-
|
|
187
|
+
shell_complete=completion.resource_ids
|
|
188
188
|
)
|
|
189
189
|
@click.option(
|
|
190
190
|
"--raw",
|
|
@@ -211,7 +211,7 @@ def inspect_command(app, resource_id, raw):
|
|
|
211
211
|
@click.argument(
|
|
212
212
|
"resource_id",
|
|
213
213
|
type=click.STRING,
|
|
214
|
-
|
|
214
|
+
shell_complete=completion.resource_ids
|
|
215
215
|
)
|
|
216
216
|
@click.option(
|
|
217
217
|
"--raw",
|
|
@@ -38,7 +38,7 @@ def _get_sorted_scheduler_ids():
|
|
|
38
38
|
nargs=-1,
|
|
39
39
|
required=True,
|
|
40
40
|
type=click.STRING,
|
|
41
|
-
|
|
41
|
+
shell_complete=completion.scheduler_ids
|
|
42
42
|
)
|
|
43
43
|
@click.option(
|
|
44
44
|
"--workflow",
|
|
@@ -121,7 +121,7 @@ def list_command(app, raw, id_only):
|
|
|
121
121
|
@click.argument(
|
|
122
122
|
"scheduler_id",
|
|
123
123
|
type=click.STRING,
|
|
124
|
-
|
|
124
|
+
shell_complete=completion.scheduler_ids
|
|
125
125
|
)
|
|
126
126
|
@click.option(
|
|
127
127
|
"--raw",
|
|
@@ -150,7 +150,7 @@ def inspect_command(app, scheduler_id, raw):
|
|
|
150
150
|
"scheduler_ids",
|
|
151
151
|
nargs=-1,
|
|
152
152
|
type=click.STRING,
|
|
153
|
-
|
|
153
|
+
shell_complete=completion.scheduler_ids
|
|
154
154
|
)
|
|
155
155
|
@click.option(
|
|
156
156
|
"-a", "--all", "all_",
|
|
@@ -198,7 +198,7 @@ def disable_command(app, scheduler_ids, all_):
|
|
|
198
198
|
"scheduler_ids",
|
|
199
199
|
nargs=-1,
|
|
200
200
|
type=click.STRING,
|
|
201
|
-
|
|
201
|
+
shell_complete=completion.scheduler_ids
|
|
202
202
|
)
|
|
203
203
|
@click.option(
|
|
204
204
|
"-a", "--all", "all_",
|