Skip to content

Commit 898b3cc

Browse files
authored
Merge pull request #243 from oslokommune/verbose
Streamline dataset listings
2 parents 09b507b + 3fe07d7 commit 898b3cc

9 files changed

Lines changed: 101 additions & 26 deletions

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* New commands `datasets delete-version`, `datasets delete-edition`, and
77
`datasets delete-distribution` for deleting dataset versions, editions, and
88
distributions respectively.
9+
* Streamlined output in the dataset listing commands.
10+
* New option `--verbose` for the `datasets ls` command which lists every
11+
relevant metadata field for the listed datasets.
912

1013
## 4.4.0 - 2025-05-14
1114

okdata/cli/commands/datasets/datasets.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class DatasetsCommand(BaseCommand):
1818
__doc__ = f"""Oslo :: Datasets
1919
2020
Usage:
21-
okdata datasets ls [--filter=<filter> options]
22-
okdata datasets ls <uri> [options]
21+
okdata datasets ls [--filter=<filter> --verbose options]
22+
okdata datasets ls <uri> [--verbose options]
2323
okdata datasets cp <source> <target> [options]
2424
okdata datasets create [options]
2525
okdata datasets create-version <dataset_id> [options]
@@ -33,7 +33,9 @@ class DatasetsCommand(BaseCommand):
3333
Examples:
3434
okdata datasets ls
3535
okdata datasets ls --filter=bydelsfakta
36+
okdata datasets ls --verbose
3637
okdata datasets ls my-dataset
38+
okdata datasets ls my-dataset --verbose
3739
okdata datasets ls my-dataset/1
3840
okdata datasets ls my-dataset/1/20240101T102030
3941
okdata datasets ls my-dataset/1/20240101T102030 --format=json
@@ -99,7 +101,10 @@ def list_metadata(self):
99101
def datasets(self):
100102
self.log.info("Listing datasets")
101103
dataset_list = self.sdk.get_datasets(filter=self.opt("filter"))
102-
out = create_output(self.opt("format"), "datasets_config.json")
104+
out = create_output(
105+
self.opt("format"),
106+
f"datasets_config{'_verbose' if self.opt('verbose') else ''}.json",
107+
)
103108
out.add_rows(dataset_list)
104109
self.print("Available datasets", out)
105110

@@ -117,7 +122,12 @@ def dataset(self, dataset_id):
117122
)
118123
return
119124

120-
out = create_output(self.opt("format"), "datasets_dataset_config.json")
125+
config = (
126+
"datasets_config_verbose"
127+
if self.opt("verbose")
128+
else "datasets_dataset_config.json"
129+
)
130+
out = create_output(self.opt("format"), config)
121131
out.add_rows([dataset])
122132
self.print(f"Dataset: {dataset_id}", out)
123133

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
{
2-
"Id": {
3-
"name": "Id",
2+
"ID": {
3+
"name": "ID",
44
"key": "Id"
55
},
6-
"Title": {
7-
"name": "Title",
8-
"key": "title"
9-
},
106
"Publisher": {
117
"name": "Publisher",
128
"key": "publisher"
9+
},
10+
"Parent ID": {
11+
"name": "Parent ID",
12+
"key": "parent_id"
13+
},
14+
"Access rights": {
15+
"name": "Access rights",
16+
"key": "accessRights"
1317
}
1418
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"ID": {
3+
"name": "ID",
4+
"key": "Id"
5+
},
6+
"Title": {
7+
"name": "Title",
8+
"key": "title"
9+
},
10+
"Description": {
11+
"name": "Description",
12+
"key": "description"
13+
},
14+
"Publisher": {
15+
"name": "Publisher",
16+
"key": "publisher"
17+
},
18+
"Objective": {
19+
"name": "Objective",
20+
"key": "objective"
21+
},
22+
"Parent ID": {
23+
"name": "Parent ID",
24+
"key": "parent_id"
25+
},
26+
"Access rights": {
27+
"name": "Access rights",
28+
"key": "accessRights"
29+
},
30+
"Theme": {
31+
"name": "Theme",
32+
"key": "theme"
33+
},
34+
"Keywords": {
35+
"name": "Keywords",
36+
"key": "keywords"
37+
},
38+
"Frequency": {
39+
"name": "Frequency",
40+
"key": "frequency"
41+
},
42+
"Contact point": {
43+
"name": "Contact Point",
44+
"key": "contactPoint",
45+
"fields": [
46+
"name",
47+
"email"
48+
]
49+
}
50+
}

okdata/cli/data/output-format/datasets_dataset_config.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
{
2+
"Title": {
3+
"name": "Title",
4+
"key": "title"
5+
},
6+
"Description": {
7+
"name": "Description",
8+
"key": "description"
9+
},
210
"Publisher": {
311
"name": "Publisher",
412
"key": "publisher"
513
},
6-
"Frequency": {
7-
"name": "Frequency",
8-
"key": "frequency"
14+
"Parent ID": {
15+
"name": "Parent ID",
16+
"key": "parent_id"
917
},
10-
"Objective": {
11-
"name": "Objective",
12-
"key": "objective"
18+
"Access rights": {
19+
"name": "Access rights",
20+
"key": "accessRights"
1321
},
14-
"ContactPoint": {
15-
"name": "Contact Point",
22+
"Contact point": {
23+
"name": "Contact point",
1624
"key": "contactPoint",
1725
"fields": [
1826
"name",

okdata/cli/data/output-format/datasets_dataset_version_config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"Id": {
3-
"name": "Id",
2+
"ID": {
3+
"name": "ID",
44
"key": "Id"
55
},
66
"Edition": {

okdata/cli/data/output-format/datasets_dataset_version_edition_config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"Id": {
3-
"name": "Id",
2+
"ID": {
3+
"name": "ID",
44
"key": "Id"
55
},
66
"Edition": {

okdata/cli/data/output-format/datasets_dataset_version_edition_distributions_config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"Id": {
3-
"name": "Id",
2+
"ID": {
3+
"name": "ID",
44
"key": "Id"
55
},
66
"Filename": {

okdata/cli/data/output-format/datasets_dataset_versions_config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"Id": {
3-
"name": "Id",
2+
"ID": {
3+
"name": "ID",
44
"key": "Id"
55
},
66
"Version": {

0 commit comments

Comments
 (0)