okdata-cli 4.1.0__tar.gz → 4.3.0__tar.gz

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.
Files changed (56) hide show
  1. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/LICENSE +1 -1
  2. {okdata-cli-4.1.0/okdata_cli.egg-info → okdata_cli-4.3.0}/PKG-INFO +18 -3
  3. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/__main__.py +7 -1
  4. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/command.py +19 -10
  5. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/datasets/datasets.py +19 -5
  6. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/datasets/questions.py +16 -4
  7. okdata_cli-4.3.0/okdata/cli/commands/datasets/wizards.py +131 -0
  8. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/pubs/pubs.py +5 -7
  9. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/pubs/questions.py +1 -0
  10. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/teams/teams.py +4 -6
  11. {okdata-cli-4.1.0 → okdata_cli-4.3.0/okdata_cli.egg-info}/PKG-INFO +18 -3
  12. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/setup.py +2 -2
  13. okdata-cli-4.1.0/okdata/cli/commands/datasets/wizards.py +0 -92
  14. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/README.md +0 -0
  15. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/__init__.py +0 -0
  16. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/__init__.py +0 -0
  17. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/__init__.py +0 -0
  18. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/datasets/__init__.py +0 -0
  19. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/permissions.py +0 -0
  20. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/pubs/__init__.py +0 -0
  21. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/pubs/client.py +0 -0
  22. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/pubs/wizards.py +0 -0
  23. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/status.py +0 -0
  24. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/teams/questions.py +0 -0
  25. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/teams/util.py +0 -0
  26. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/teams/wizards.py +0 -0
  27. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/validators.py +0 -0
  28. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/commands/wizard.py +0 -0
  29. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/datasets_config.json +0 -0
  30. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/datasets_copy_file_config.json +0 -0
  31. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/datasets_copy_file_config_2.json +0 -0
  32. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/datasets_dataset_config.json +0 -0
  33. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/datasets_dataset_version_config.json +0 -0
  34. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/datasets_dataset_version_edition_config.json +0 -0
  35. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/datasets_dataset_version_edition_distributions_config.json +0 -0
  36. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/datasets_dataset_versions_config.json +0 -0
  37. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/my_permissions_config.json +0 -0
  38. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/permissions_config.json +0 -0
  39. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/pubs_audit_log_config.json +0 -0
  40. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/pubs_clients_config.json +0 -0
  41. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/pubs_multiple_client_keys_config.json +0 -0
  42. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/pubs_single_client_keys_config.json +0 -0
  43. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/status_config.json +0 -0
  44. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/status_history_config.json +0 -0
  45. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/team_members_config.json +0 -0
  46. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/data/output-format/teams_config.json +0 -0
  47. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/io.py +0 -0
  48. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata/cli/output.py +0 -0
  49. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata_cli.egg-info/SOURCES.txt +0 -0
  50. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata_cli.egg-info/dependency_links.txt +0 -0
  51. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata_cli.egg-info/entry_points.txt +0 -0
  52. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata_cli.egg-info/namespace_packages.txt +0 -0
  53. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata_cli.egg-info/requires.txt +0 -0
  54. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/okdata_cli.egg-info/top_level.txt +0 -0
  55. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/pyproject.toml +0 -0
  56. {okdata-cli-4.1.0 → okdata_cli-4.3.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Oslo Origo
3
+ Copyright (c) 2019-2024 Oslo Origo
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
@@ -1,10 +1,10 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: okdata-cli
3
- Version: 4.1.0
3
+ Version: 4.3.0
4
4
  Summary: CLI for services provided by Oslo Origo
5
5
  Home-page: https://github.com/oslokommune/okdata-cli/
6
6
  Author: Oslo Origo
7
- Author-email: dataplattform@oslo.kommune.no
7
+ Author-email: dataspeilet@oslo.kommune.no
8
8
  License: MIT
9
9
  Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Programming Language :: Python :: 3.8
@@ -17,6 +17,21 @@ Classifier: Operating System :: OS Independent
17
17
  Requires-Python: >=3.8
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
+ Requires-Dist: PrettyTable
21
+ Requires-Dist: docopt
22
+ Requires-Dist: okdata-sdk<4,>=3.1.1
23
+ Requires-Dist: questionary<2.0.0,>=1.10.0
24
+ Requires-Dist: requests
25
+ Dynamic: author
26
+ Dynamic: author-email
27
+ Dynamic: classifier
28
+ Dynamic: description
29
+ Dynamic: description-content-type
30
+ Dynamic: home-page
31
+ Dynamic: license
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
20
35
 
21
36
  # `okdata-cli`: Oslo Origo data services CLI
22
37
 
@@ -16,9 +16,15 @@ from okdata.cli.commands.teams.teams import TeamsCommand
16
16
 
17
17
  def main():
18
18
  argv = sys.argv
19
- if len(argv) < 2 or argv[1] == "help":
19
+ if len(argv) < 2:
20
20
  BaseCommand().help()
21
21
  return
22
+ if argv[1] in ("-e", "--environment"):
23
+ BaseCommand().print_env()
24
+ return
25
+ if argv[1] in ("-v", "--version"):
26
+ BaseCommand().print_version()
27
+ return
22
28
 
23
29
  command = get_command_class(argv)
24
30
 
@@ -24,7 +24,9 @@ usage:
24
24
  okdata pubs [options]
25
25
  okdata status [options]
26
26
  okdata teams [options]
27
+ okdata -e | --environment
27
28
  okdata -h | --help
29
+ okdata -v | --version
28
30
 
29
31
  Commands available:
30
32
  datasets
@@ -89,16 +91,6 @@ Options:{BASE_COMMAND_OPTIONS}
89
91
  else:
90
92
  print(payload)
91
93
 
92
- def confirm_to_continue(self, message):
93
- """Ask the user for confirmation before continuing.
94
-
95
- Any answer other than "y" will exit the program.
96
- """
97
- self.print(message)
98
- if input("Continue? [y/N]: ") != "y":
99
- self.print("Abort.")
100
- sys.exit()
101
-
102
94
  def login(self):
103
95
  self.sdk.login()
104
96
 
@@ -119,6 +111,12 @@ Options:{BASE_COMMAND_OPTIONS}
119
111
  def help(self):
120
112
  print(self.__doc__, end="")
121
113
 
114
+ def print_env(self):
115
+ print(self.sdk.config.resolve_environment(None))
116
+
117
+ def print_version(self):
118
+ print(self.version)
119
+
122
120
  def print_error_response(self, response_body):
123
121
  if not isinstance(response_body, dict):
124
122
  print(response_body)
@@ -140,6 +138,17 @@ Options:{BASE_COMMAND_OPTIONS}
140
138
  print(response_body)
141
139
 
142
140
 
141
+ def confirm_to_continue(message):
142
+ """Ask the user for confirmation before continuing.
143
+
144
+ Any answer other than "y" will exit the program.
145
+ """
146
+ print(message)
147
+ if input("Continue? [y/N]: ") != "y":
148
+ print("Abort.")
149
+ sys.exit()
150
+
151
+
143
152
  def _format_error_message(message, errors=None):
144
153
  msg = f"An error occurred: {message}"
145
154
  sep = "\n - "
@@ -6,7 +6,10 @@ from okdata.sdk.data.upload import Upload
6
6
  from requests.exceptions import HTTPError
7
7
 
8
8
  from okdata.cli.command import BaseCommand, BASE_COMMAND_OPTIONS
9
- from okdata.cli.commands.datasets.wizards import DatasetCreateWizard
9
+ from okdata.cli.commands.datasets.wizards import (
10
+ DatasetCreateWizard,
11
+ PipelineCreateWizard,
12
+ )
10
13
  from okdata.cli.io import read_json, resolve_output_filepath
11
14
  from okdata.cli.output import create_output
12
15
 
@@ -22,6 +25,7 @@ Usage:
22
25
  okdata datasets create-version <datasetid> [options]
23
26
  okdata datasets create-edition <datasetid> [<versionid>] [options]
24
27
  okdata datasets create-distribution <datasetid> [<versionid> <editionid>] [options]
28
+ okdata datasets create-pipeline <datasetid> [options]
25
29
 
26
30
  Examples:
27
31
  okdata datasets ls
@@ -32,6 +36,7 @@ Examples:
32
36
  okdata datasets ls my-dataset/1/20240101T102030 --format=json
33
37
  okdata datasets create --file=dataset.json
34
38
  okdata datasets cp /tmp/file.csv ds:my-dataset-id
39
+ okdata datasets create-pipeline my-dataset
35
40
 
36
41
  Options:{BASE_COMMAND_OPTIONS}
37
42
  --file=<file> # Use this file for configuration or upload
@@ -60,6 +65,8 @@ Options:{BASE_COMMAND_OPTIONS}
60
65
  self.create_edition()
61
66
  elif self.cmd("create-distribution"):
62
67
  self.create_distribution()
68
+ elif self.cmd("create-pipeline"):
69
+ PipelineCreateWizard(self, self.arg("datasetid")).start()
63
70
  else:
64
71
  self.help()
65
72
 
@@ -261,9 +268,9 @@ Options:{BASE_COMMAND_OPTIONS}
261
268
  )
262
269
 
263
270
  def _dataset_components_from_uri(
264
- self, dataset_uri, create_edition=False, auto_resolve=True
271
+ self, uri, create_edition=False, auto_resolve=True
265
272
  ):
266
- """Return an ID/version/edition tuple given a dataset URI.
273
+ """Return a dataset ID/version/edition tuple given a URI.
267
274
 
268
275
  Four different URI formats are supported:
269
276
 
@@ -289,8 +296,15 @@ Options:{BASE_COMMAND_OPTIONS}
289
296
 
290
297
  Otherwise `None` is returned for missing parts.
291
298
  """
292
- parts = dataset_uri.split("/")
293
- dataset_id, version, edition = parts + [None] * (3 - len(parts))
299
+ parts = uri.split("/")
300
+
301
+ try:
302
+ dataset_id, version, edition = parts + [None] * (3 - len(parts))
303
+ except ValueError:
304
+ sys.exit(
305
+ "URI must be on the format 'dataset_id', "
306
+ "'dataset_id/version', or 'dataset_id/version/edition'."
307
+ )
294
308
 
295
309
  # First verify that the dataset exists; `get_dataset` raises an error
296
310
  # if not.
@@ -26,7 +26,7 @@ available_pipelines = [
26
26
  ]
27
27
 
28
28
 
29
- def qs_create():
29
+ def qs_create_dataset():
30
30
  return [
31
31
  {
32
32
  **required_style,
@@ -35,7 +35,7 @@ def qs_create():
35
35
  "message": "Datakilde",
36
36
  "choices": [
37
37
  Choice("Fil", "file"),
38
- Choice("Database (krever eget databaseoppsett)", "database"),
38
+ Choice("Punktmålinger", "event"),
39
39
  Choice("Ingen (datasettet skal ikke inneholde data direkte)", "none"),
40
40
  ],
41
41
  },
@@ -62,9 +62,9 @@ def qs_create():
62
62
  "name": "accessRights",
63
63
  "message": "Tilgangsnivå",
64
64
  "choices": [
65
+ Choice("Eksplisitt tilgangskontroll", "non-public"),
66
+ Choice("Internt til Origo", "restricted"),
65
67
  Choice("Offentlig", "public"),
66
- Choice("Begrenset offentlighet", "restricted"),
67
- Choice("Unntatt offentlighet", "non-public"),
68
68
  ],
69
69
  },
70
70
  {
@@ -114,3 +114,15 @@ def qs_create():
114
114
  "when": lambda x: x["sourceType"] in pipeline_choices,
115
115
  },
116
116
  ]
117
+
118
+
119
+ def qs_create_pipeline():
120
+ return [
121
+ {
122
+ **required_style,
123
+ "type": "select",
124
+ "name": "pipeline",
125
+ "message": "Prosessering",
126
+ "choices": pipeline_choices["file"],
127
+ },
128
+ ]
@@ -0,0 +1,131 @@
1
+ import sys
2
+
3
+ from okdata.sdk.data.dataset import Dataset
4
+ from okdata.sdk.pipelines.client import PipelineApiClient
5
+ from requests import HTTPError
6
+
7
+ from okdata.cli.command import confirm_to_continue
8
+ from okdata.cli.commands.datasets.questions import qs_create_dataset, qs_create_pipeline
9
+ from okdata.cli.commands.wizard import run_questionnaire
10
+
11
+
12
+ def _pipeline_config(pipeline_processor_id, dataset_id, version):
13
+ return {
14
+ "pipelineProcessorId": pipeline_processor_id,
15
+ "id": dataset_id,
16
+ "datasetUri": f"output/{dataset_id}/{version}",
17
+ }
18
+
19
+
20
+ def _pipeline_input_config(pipeline_id, dataset_id, version):
21
+ return {
22
+ "pipelineInstanceId": pipeline_id,
23
+ "datasetUri": f"input/{dataset_id}/{version}",
24
+ "stage": "raw",
25
+ }
26
+
27
+
28
+ def _create_pipeline(command, env, dataset_id, pipeline):
29
+ command.print("Creating pipeline...")
30
+ pipeline_client = PipelineApiClient(env=env)
31
+ pipeline_config = _pipeline_config(pipeline, dataset_id, "1")
32
+ pipeline_id = pipeline_client.create_pipeline_instance(pipeline_config)
33
+ pipeline_id = pipeline_id.strip('"') # What's up with these?
34
+ command.print(f"Created pipeline with ID: {pipeline_id}")
35
+
36
+ command.print("Creating pipeline input...")
37
+ pipeline_input_config = _pipeline_input_config(pipeline_id, dataset_id, "1")
38
+ pipeline_input_id = pipeline_client.create_pipeline_input(pipeline_input_config)
39
+ pipeline_input_id = pipeline_input_id.strip('"') # What's up with these?
40
+ command.print(f"Created pipeline input with ID: {pipeline_input_id}")
41
+
42
+
43
+ class DatasetCreateWizard:
44
+ """Wizard for the `datasets create` command.
45
+
46
+ Creates a new dataset with an optional pipeline based on the answers from a
47
+ questionnaire.
48
+ """
49
+
50
+ def __init__(self, command):
51
+ self.command = command
52
+
53
+ def dataset_config(self, choices):
54
+ title = choices["title"]
55
+ access_rights = choices["accessRights"]
56
+
57
+ config = {
58
+ "title": title,
59
+ "description": choices["description"] or title,
60
+ "keywords": choices["keywords"],
61
+ "accessRights": access_rights,
62
+ "source": {"type": choices["sourceType"]},
63
+ "objective": choices["objective"] or title,
64
+ "contactPoint": {
65
+ "name": choices["name"],
66
+ "email": choices["email"],
67
+ },
68
+ "publisher": choices["publisher"],
69
+ }
70
+
71
+ if choices.get("license"):
72
+ config["license"] = choices["license"]
73
+
74
+ return config
75
+
76
+ def start(self):
77
+ env = self.command.opt("env")
78
+ choices = run_questionnaire(*qs_create_dataset())
79
+
80
+ confirm_to_continue(
81
+ "Will create a new dataset '{}'.{}".format(
82
+ choices["title"],
83
+ (
84
+ "\n\nData uploaded to the dataset will be PUBLICLY AVAILABLE ON THE INTERNET.\n"
85
+ if choices["accessRights"] == "public"
86
+ else ""
87
+ ),
88
+ )
89
+ )
90
+
91
+ self.command.print("Creating dataset...")
92
+ dataset_client = Dataset(env=env)
93
+ dataset_config = self.dataset_config(choices)
94
+ dataset = dataset_client.create_dataset(dataset_config)
95
+ dataset_id = dataset["Id"]
96
+ self.command.print(f"Created dataset with ID: {dataset_id}")
97
+
98
+ if choices.get("pipeline"):
99
+ _create_pipeline(self.command, env, dataset_id, choices["pipeline"])
100
+
101
+ if choices["sourceType"] == "file":
102
+ self.command.print(
103
+ f"""Done! You may go ahead and upload data to the dataset by running:
104
+
105
+ okdata datasets cp FILE ds:{dataset_id}
106
+ """
107
+ )
108
+ else:
109
+ self.command.print("Done!")
110
+
111
+
112
+ class PipelineCreateWizard:
113
+ """Wizard for the `datasets create-pipeline` command."""
114
+
115
+ def __init__(self, command, dataset_id):
116
+ self.command = command
117
+ self.dataset_id = dataset_id
118
+
119
+ def start(self):
120
+ choices = run_questionnaire(*qs_create_pipeline())
121
+ try:
122
+ _create_pipeline(
123
+ self.command,
124
+ self.command.opt("env"),
125
+ self.dataset_id,
126
+ choices["pipeline"],
127
+ )
128
+ except HTTPError as e:
129
+ if e.response.status_code == 409:
130
+ sys.exit("This dataset already has a pipeline set up.")
131
+ raise
@@ -5,7 +5,7 @@ from operator import itemgetter
5
5
  from okdata.sdk.team.client import TeamClient
6
6
 
7
7
  from okdata.cli import MAINTAINER
8
- from okdata.cli.command import BASE_COMMAND_OPTIONS, BaseCommand
8
+ from okdata.cli.command import BASE_COMMAND_OPTIONS, BaseCommand, confirm_to_continue
9
9
  from okdata.cli.commands.pubs.client import PubsClient
10
10
  from okdata.cli.commands.pubs.questions import (
11
11
  NoClientsError,
@@ -88,7 +88,7 @@ Options:{BASE_COMMAND_OPTIONS}
88
88
  scopes = config["scopes"]
89
89
  env = config["env"]
90
90
 
91
- self.confirm_to_continue(
91
+ confirm_to_continue(
92
92
  "Will create a new {} client{} in {}{}.".format(
93
93
  client_types[client_type_id],
94
94
  f" for {providers[provider_id]}" if provider_id else "",
@@ -138,7 +138,7 @@ You may now go ahead and create a key for it by running:
138
138
  aws_account = choices["aws_account"]
139
139
  aws_region = choices["aws_region"]
140
140
 
141
- self.confirm_to_continue(
141
+ confirm_to_continue(
142
142
  "Will delete client '{}' [{}]{}.".format(
143
143
  client_name,
144
144
  env,
@@ -241,7 +241,7 @@ You may now go ahead and create a key for it by running:
241
241
  aws_region = config["aws_region"]
242
242
  enable_auto_rotate = config["enable_auto_rotate"]
243
243
 
244
- self.confirm_to_continue(
244
+ confirm_to_continue(
245
245
  "\n\n".join(
246
246
  [
247
247
  "Will create a new key for client '{}' in {} and {}.".format(
@@ -327,9 +327,7 @@ You may now go ahead and create a key for it by running:
327
327
  client_name = choices["client_name"]
328
328
  key_id = choices["key_id"]
329
329
 
330
- self.confirm_to_continue(
331
- f"Will delete key '{key_id}' from '{client_name}' [{env}]."
332
- )
330
+ confirm_to_continue(f"Will delete key '{key_id}' from '{client_name}' [{env}].")
333
331
 
334
332
  self.print(f"Deleting key '{key_id}' from '{client_name}' [{env}]...")
335
333
  self.pubs_client.delete_key(env, client_id, key_id)
@@ -216,6 +216,7 @@ def q_delete_from_aws():
216
216
  "name": "delete_from_aws",
217
217
  "message": "Delete key from AWS Parameter Store?",
218
218
  "auto_enter": False,
219
+ "default": False,
219
220
  }
220
221
 
221
222
 
@@ -3,7 +3,7 @@ from operator import itemgetter
3
3
  from okdata.sdk.team.client import TeamClient
4
4
 
5
5
  from okdata.cli import MAINTAINER
6
- from okdata.cli.command import BASE_COMMAND_OPTIONS, BaseCommand
6
+ from okdata.cli.command import BASE_COMMAND_OPTIONS, BaseCommand, confirm_to_continue
7
7
  from okdata.cli.commands.teams.questions import NoTeamError
8
8
  from okdata.cli.commands.teams.util import (
9
9
  member_representation,
@@ -122,9 +122,7 @@ Options:{BASE_COMMAND_OPTIONS}
122
122
  )
123
123
  return
124
124
 
125
- self.confirm_to_continue(
126
- "Add {} to the team?".format(member_representation(user))
127
- )
125
+ confirm_to_continue("Add {} to the team?".format(member_representation(user)))
128
126
 
129
127
  self.client.update_team_members(
130
128
  config["team_id"], team_members + [user["username"]]
@@ -150,13 +148,13 @@ Options:{BASE_COMMAND_OPTIONS}
150
148
  members_to_keep.append(member)
151
149
 
152
150
  if len(members_to_keep) == 0:
153
- self.confirm_to_continue(
151
+ confirm_to_continue(
154
152
  "You are about to delete all members from the team, including "
155
153
  "yourself. It will not be possible to edit this team any "
156
154
  "further without being re-added by a systems administrator."
157
155
  )
158
156
  else:
159
- self.confirm_to_continue(
157
+ confirm_to_continue(
160
158
  "Remove the following member{} from the team?\n - {}".format(
161
159
  "s" if len(members_to_remove) > 1 else "",
162
160
  "\n - ".join(
@@ -1,10 +1,10 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: okdata-cli
3
- Version: 4.1.0
3
+ Version: 4.3.0
4
4
  Summary: CLI for services provided by Oslo Origo
5
5
  Home-page: https://github.com/oslokommune/okdata-cli/
6
6
  Author: Oslo Origo
7
- Author-email: dataplattform@oslo.kommune.no
7
+ Author-email: dataspeilet@oslo.kommune.no
8
8
  License: MIT
9
9
  Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Programming Language :: Python :: 3.8
@@ -17,6 +17,21 @@ Classifier: Operating System :: OS Independent
17
17
  Requires-Python: >=3.8
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
+ Requires-Dist: PrettyTable
21
+ Requires-Dist: docopt
22
+ Requires-Dist: okdata-sdk<4,>=3.1.1
23
+ Requires-Dist: questionary<2.0.0,>=1.10.0
24
+ Requires-Dist: requests
25
+ Dynamic: author
26
+ Dynamic: author-email
27
+ Dynamic: classifier
28
+ Dynamic: description
29
+ Dynamic: description-content-type
30
+ Dynamic: home-page
31
+ Dynamic: license
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
20
35
 
21
36
  # `okdata-cli`: Oslo Origo data services CLI
22
37
 
@@ -5,9 +5,9 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="okdata-cli",
8
- version="4.1.0",
8
+ version="4.3.0",
9
9
  author="Oslo Origo",
10
- author_email="dataplattform@oslo.kommune.no",
10
+ author_email="dataspeilet@oslo.kommune.no",
11
11
  description="CLI for services provided by Oslo Origo",
12
12
  license="MIT",
13
13
  long_description=long_description,
@@ -1,92 +0,0 @@
1
- from okdata.sdk.data.dataset import Dataset
2
- from okdata.sdk.pipelines.client import PipelineApiClient
3
-
4
- from okdata.cli.commands.datasets.questions import qs_create
5
- from okdata.cli.commands.wizard import run_questionnaire
6
-
7
-
8
- class DatasetCreateWizard:
9
- """Wizard for the `datasets create` command.
10
-
11
- Creates a new dataset with an optional pipeline based on the answers from a
12
- questionnaire.
13
- """
14
-
15
- def __init__(self, command):
16
- self.command = command
17
-
18
- def dataset_config(self, choices):
19
- title = choices["title"]
20
- access_rights = choices["accessRights"]
21
-
22
- config = {
23
- "title": title,
24
- "description": choices["description"] or title,
25
- "keywords": choices["keywords"],
26
- "accessRights": access_rights,
27
- "source": {"type": choices["sourceType"]},
28
- "objective": choices["objective"] or title,
29
- "contactPoint": {
30
- "name": choices["name"],
31
- "email": choices["email"],
32
- },
33
- "publisher": choices["publisher"],
34
- }
35
-
36
- if choices.get("license"):
37
- config["license"] = choices["license"]
38
-
39
- return config
40
-
41
- def pipeline_config(self, pipeline_processor_id, dataset_id, version):
42
- return {
43
- "pipelineProcessorId": pipeline_processor_id,
44
- "id": dataset_id,
45
- "datasetUri": f"output/{dataset_id}/{version}",
46
- }
47
-
48
- def pipeline_input_config(self, pipeline_id, dataset_id, version):
49
- return {
50
- "pipelineInstanceId": pipeline_id,
51
- "datasetUri": f"input/{dataset_id}/{version}",
52
- "stage": "raw",
53
- }
54
-
55
- def start(self):
56
- env = self.command.opt("env")
57
- choices = run_questionnaire(*qs_create())
58
-
59
- self.command.print("Creating dataset...")
60
- dataset_client = Dataset(env=env)
61
- dataset_config = self.dataset_config(choices)
62
- dataset = dataset_client.create_dataset(dataset_config)
63
- dataset_id = dataset["Id"]
64
- self.command.print(f"Created dataset with ID: {dataset_id}")
65
-
66
- if choices.get("pipeline"):
67
- self.command.print("Creating pipeline...")
68
- pipeline_client = PipelineApiClient(env=env)
69
- pipeline_config = self.pipeline_config(choices["pipeline"], dataset_id, "1")
70
- pipeline_id = pipeline_client.create_pipeline_instance(pipeline_config)
71
- pipeline_id = pipeline_id.strip('"') # What's up with these?
72
- self.command.print(f"Created pipeline with ID: {pipeline_id}")
73
-
74
- self.command.print("Creating pipeline input...")
75
- pipeline_input_config = self.pipeline_input_config(
76
- pipeline_id, dataset_id, "1"
77
- )
78
- pipeline_input_id = pipeline_client.create_pipeline_input(
79
- pipeline_input_config
80
- )
81
- pipeline_input_id = pipeline_input_id.strip('"') # What's up with these?
82
- self.command.print(f"Created pipeline input with ID: {pipeline_input_id}")
83
-
84
- if choices["sourceType"] == "file":
85
- self.command.print(
86
- f"""Done! You may go ahead and upload data to the dataset by running:
87
-
88
- okdata datasets cp FILE ds:{dataset_id}
89
- """
90
- )
91
- else:
92
- self.command.print("Done!")
File without changes
File without changes
File without changes
File without changes