okdata-cli 4.2.0__tar.gz → 4.3.1__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 (55) hide show
  1. {okdata-cli-4.2.0/okdata_cli.egg-info → okdata_cli-4.3.1}/PKG-INFO +17 -2
  2. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/datasets/datasets.py +19 -5
  3. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/datasets/questions.py +14 -2
  4. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/datasets/wizards.py +59 -32
  5. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/pubs/questions.py +2 -0
  6. {okdata-cli-4.2.0 → okdata_cli-4.3.1/okdata_cli.egg-info}/PKG-INFO +17 -2
  7. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/setup.py +1 -1
  8. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/LICENSE +0 -0
  9. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/README.md +0 -0
  10. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/__init__.py +0 -0
  11. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/__init__.py +0 -0
  12. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/__main__.py +0 -0
  13. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/command.py +0 -0
  14. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/__init__.py +0 -0
  15. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/datasets/__init__.py +0 -0
  16. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/permissions.py +0 -0
  17. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/pubs/__init__.py +0 -0
  18. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/pubs/client.py +0 -0
  19. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/pubs/pubs.py +0 -0
  20. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/pubs/wizards.py +0 -0
  21. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/status.py +0 -0
  22. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/teams/questions.py +0 -0
  23. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/teams/teams.py +0 -0
  24. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/teams/util.py +0 -0
  25. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/teams/wizards.py +0 -0
  26. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/validators.py +0 -0
  27. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/commands/wizard.py +0 -0
  28. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/datasets_config.json +0 -0
  29. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/datasets_copy_file_config.json +0 -0
  30. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/datasets_copy_file_config_2.json +0 -0
  31. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/datasets_dataset_config.json +0 -0
  32. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/datasets_dataset_version_config.json +0 -0
  33. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/datasets_dataset_version_edition_config.json +0 -0
  34. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/datasets_dataset_version_edition_distributions_config.json +0 -0
  35. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/datasets_dataset_versions_config.json +0 -0
  36. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/my_permissions_config.json +0 -0
  37. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/permissions_config.json +0 -0
  38. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/pubs_audit_log_config.json +0 -0
  39. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/pubs_clients_config.json +0 -0
  40. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/pubs_multiple_client_keys_config.json +0 -0
  41. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/pubs_single_client_keys_config.json +0 -0
  42. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/status_config.json +0 -0
  43. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/status_history_config.json +0 -0
  44. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/team_members_config.json +0 -0
  45. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/data/output-format/teams_config.json +0 -0
  46. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/io.py +0 -0
  47. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata/cli/output.py +0 -0
  48. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata_cli.egg-info/SOURCES.txt +0 -0
  49. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata_cli.egg-info/dependency_links.txt +0 -0
  50. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata_cli.egg-info/entry_points.txt +0 -0
  51. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata_cli.egg-info/namespace_packages.txt +0 -0
  52. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata_cli.egg-info/requires.txt +0 -0
  53. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/okdata_cli.egg-info/top_level.txt +0 -0
  54. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/pyproject.toml +0 -0
  55. {okdata-cli-4.2.0 → okdata_cli-4.3.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: okdata-cli
3
- Version: 4.2.0
3
+ Version: 4.3.1
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
@@ -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
 
@@ -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
  },
@@ -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
+ ]
@@ -1,11 +1,45 @@
1
+ import sys
2
+
1
3
  from okdata.sdk.data.dataset import Dataset
2
4
  from okdata.sdk.pipelines.client import PipelineApiClient
5
+ from requests import HTTPError
3
6
 
4
7
  from okdata.cli.command import confirm_to_continue
5
- from okdata.cli.commands.datasets.questions import qs_create
8
+ from okdata.cli.commands.datasets.questions import qs_create_dataset, qs_create_pipeline
6
9
  from okdata.cli.commands.wizard import run_questionnaire
7
10
 
8
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
+
9
43
  class DatasetCreateWizard:
10
44
  """Wizard for the `datasets create` command.
11
45
 
@@ -39,23 +73,9 @@ class DatasetCreateWizard:
39
73
 
40
74
  return config
41
75
 
42
- def pipeline_config(self, pipeline_processor_id, dataset_id, version):
43
- return {
44
- "pipelineProcessorId": pipeline_processor_id,
45
- "id": dataset_id,
46
- "datasetUri": f"output/{dataset_id}/{version}",
47
- }
48
-
49
- def pipeline_input_config(self, pipeline_id, dataset_id, version):
50
- return {
51
- "pipelineInstanceId": pipeline_id,
52
- "datasetUri": f"input/{dataset_id}/{version}",
53
- "stage": "raw",
54
- }
55
-
56
76
  def start(self):
57
77
  env = self.command.opt("env")
58
- choices = run_questionnaire(*qs_create())
78
+ choices = run_questionnaire(*qs_create_dataset())
59
79
 
60
80
  confirm_to_continue(
61
81
  "Will create a new dataset '{}'.{}".format(
@@ -76,22 +96,7 @@ class DatasetCreateWizard:
76
96
  self.command.print(f"Created dataset with ID: {dataset_id}")
77
97
 
78
98
  if choices.get("pipeline"):
79
- self.command.print("Creating pipeline...")
80
- pipeline_client = PipelineApiClient(env=env)
81
- pipeline_config = self.pipeline_config(choices["pipeline"], dataset_id, "1")
82
- pipeline_id = pipeline_client.create_pipeline_instance(pipeline_config)
83
- pipeline_id = pipeline_id.strip('"') # What's up with these?
84
- self.command.print(f"Created pipeline with ID: {pipeline_id}")
85
-
86
- self.command.print("Creating pipeline input...")
87
- pipeline_input_config = self.pipeline_input_config(
88
- pipeline_id, dataset_id, "1"
89
- )
90
- pipeline_input_id = pipeline_client.create_pipeline_input(
91
- pipeline_input_config
92
- )
93
- pipeline_input_id = pipeline_input_id.strip('"') # What's up with these?
94
- self.command.print(f"Created pipeline input with ID: {pipeline_input_id}")
99
+ _create_pipeline(self.command, env, dataset_id, choices["pipeline"])
95
100
 
96
101
  if choices["sourceType"] == "file":
97
102
  self.command.print(
@@ -102,3 +107,25 @@ class DatasetCreateWizard:
102
107
  )
103
108
  else:
104
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
@@ -43,6 +43,7 @@ _scopes = {
43
43
  "skatteetaten:skatteplikt",
44
44
  "skatteetaten:spesifisertsummertskattegrunnlag",
45
45
  "skatteetaten:summertskattegrunnlag",
46
+ "skatteetaten:testnorge/testdata.read",
46
47
  "skatteetaten:tjenestepensjonsavtale",
47
48
  ],
48
49
  }
@@ -216,6 +217,7 @@ def q_delete_from_aws():
216
217
  "name": "delete_from_aws",
217
218
  "message": "Delete key from AWS Parameter Store?",
218
219
  "auto_enter": False,
220
+ "default": False,
219
221
  }
220
222
 
221
223
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: okdata-cli
3
- Version: 4.2.0
3
+ Version: 4.3.1
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
@@ -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,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="okdata-cli",
8
- version="4.2.0",
8
+ version="4.3.1",
9
9
  author="Oslo Origo",
10
10
  author_email="dataspeilet@oslo.kommune.no",
11
11
  description="CLI for services provided by Oslo Origo",
File without changes
File without changes
File without changes
File without changes
File without changes