You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: quality of life improvements and further docs
- replaces all calls of GetUserFiles() with GetUserFilesWithPrefix()
since it should be much more performant and less prone for errors
- adding shorthand aliases for `--config` and `--data-directory` to
make usage easier
- formatting
- adding documentation to try and clarify different uses between
running as a cli and running as a job
Copy file name to clipboardExpand all lines: README.md
+32-4Lines changed: 32 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,10 @@
1
1
# sda-bpctl
2
2
3
-
4
3
A tool that can be used to deal with administrative workflows for the big picture project. It supports three primary functions, making data ingestion, assigning accession ids to each ingested file, and creating a dataset for all files ingested with a accession id.
5
4
6
-
It can be used either locally as a cli tool or be packaged and run as a job in kubernetes.
5
+
It can be used either locally as a cli tool or be packaged and run as a job in kubernetes. This is on one hand powerfull and on the other hand, sometimes confusing and unintuitive, in an attempt to clarify the differance in logic based on how the tool is used the terms used will be **job** and **cli** in **bold** when describing the different logics.
6
+
7
+
The core logic of this tool is wrapping logic around the sensetive data archive (SDA) api. To fully understand how this is expected to work you should be familiar with the sda and it's api.
7
8
8
9
### installation
9
10
@@ -27,6 +28,7 @@ Commands must be one of:
27
28
-`dataset`
28
29
-`mail`
29
30
-`job`
31
+
-`render`
30
32
31
33
#### examples
32
34
@@ -63,10 +65,8 @@ and apply it using `kubectl`:
63
65
kubectl apply -f job.yaml
64
66
```
65
67
66
-
67
68
will render a job.yaml manifest for you based on the configuration values you have supplied
68
69
69
-
70
70
### configuration
71
71
72
72
bpctl can consume configuration from either `config.yaml` or from environment variables. If both are supplied then the environment variables will take priority. If using config.yaml it is expected to be located in the root directory of the project. It can also be supplied by using the `--config` flag if located elsewhere.
@@ -77,6 +77,8 @@ see the `config.yaml.example` for a base template with what fields to fill
77
77
| USER_ID | "user-1234" | The user ID for the uploader, acts as identifier for the uploaded data |`ingest`, `accession`, `dataset`, `job`, `render`|
78
78
| DATASET_ID | "aa-Dataset-abc" | The ID that will be set for the finalized dataset, will be used during the `dataset` command |`ingest`, `accession`, `dataset`, `job`, `mail`, `render`|
79
79
| DATASET_FOLDER | "DATASET_ABC" | The folder where the uploaded data resides in s3inbox |`ingest`, `accession`, `dataset`, `job`, `mail`, `render`|
80
+
| JOB_TIMEOUT | 3 | A integer value, representing the number of minutes before the job times out when waiting for `accession`|`job`, `render`|
81
+
| JOB_POLL_RATE | 2 | A integer value, representing the number of miutes between each polling intervall when waiting for `accession`, needs to be less than the `JOB_TIMEOUT` value |`job`, `render`|
80
82
| JOB_EXPECTED_NR_FILES | 0 | The expected number of files to be part of the finalized dataset, set this when using `render` to include it in the rendered job.yaml |`job`, `render`|
81
83
| CLIENT_API_HOST | "https://api.example.com"| The hostname for the SDA API to communicate with |`ingest`, `accession`, `dataset`, `job`|
82
84
| CLIENT_ACCESS_TOKEN | "youraccesstoken" | The access token to authenticate towards the client api host | Yes |`ingest`, `accession`, `dataset`, `job`|
@@ -89,6 +91,32 @@ see the `config.yaml.example` for a base template with what fields to fill
89
91
| DB_SECRET_NAME | "db-secret" | The name of the kubernetes secret that holds connection details for the sda database |`job` ,`render`|
90
92
| CERT_SECRET_NAME | "cert-secret" | The name of the kubernetes secret that holds a tls certificate to use |`job`, `render`|
91
93
94
+
### ingest
95
+
96
+
The ingtest command will lookup all the files for the `USER_ID` that resides in `DATASET_FOLDER`, filter out all files that are not in either a directory `LANDING_PAGE` or `PRIVATE` and any file that does not have the event `uploaded`.
97
+
98
+
**job:** the number of files retrieved will be compared to the `JOB_EXPECTED_NR_FILES` value, if they match the files will be sent for ingestion. If not the job will fail.
99
+
100
+
**cli:** the files found will be sent for ingestion without evaluation. In that case the responsibility is on the user to ensure with a `--dry-run` before that the number of files are the desired ammount.
101
+
102
+
Files sent to ingestion are done so trough the sda api `POST /ingest` endpoint.
103
+
104
+
### accession
105
+
106
+
The accession command will get a list of files for the `USER_ID` that resides in `DATASET_FOLDER` and have the event `verified`.
107
+
108
+
**job:** will poll the api according to `JOB_POLL_RATE` and wait untill it finds the ammount of files that matches `JOB_EXPECTED_NR_FILES` or untill it times out according to `JOB_TIMEOUT`. When the expected number of files are found it will send a request to the sda api `POST /accession` endpoint with the files.
109
+
110
+
**cli:** will try create a file called `<DATASET_FODLER>-fileIDs.txt` in the `--data-directory` directory. It will retreive the list of files and after successfull call to `POST /accession` it will write the accessionIDs to the file `<DATASET_FOLDER>-fileIDs.txt`. This is legacy logic owned from the `ingestor.sh` scipt and makes it so that you can store a intermidate state and keep track of the accession ids retrieved between runs of `accession` and `dataset`.
111
+
112
+
### dataset
113
+
114
+
The dataset command will retrieve a list of accessionIDs and send a request to the sda api `POST /dataset`
115
+
116
+
**job:** will consume the list of accessionIDs by a in memory variable produced by the previous step in `accession` and send a list of files to be mapped to a dataset to `POST /dataset/create`
117
+
118
+
**cli:** will try to read from `<DATASET_FOLDER>-fileIDs.txt` to identify the files to be included in a dataset. If the file cannot be found it will make a call to `GET /user/files?path_prefix=<DATASET_FOLDER>` to find them and send a request to `POST /dataset/create` with the files.
119
+
92
120
### testing
93
121
94
122
Unit tests using [pkg.go.dev/testing](https://pkg.go.dev/testing)
Copy file name to clipboardExpand all lines: internal/accession/accession.go
+4-5Lines changed: 4 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ var accessionCmd = &cobra.Command{
51
51
}
52
52
deferfile.Close() //nolint:errcheck
53
53
54
-
files, err:=api.GetUsersFiles()
54
+
files, err:=api.GetUsersFilesWithPrefix()
55
55
iferr!=nil {
56
56
returnerr
57
57
}
@@ -80,13 +80,13 @@ var accessionCmd = &cobra.Command{
80
80
funcinit() {
81
81
cmd.AddCommand(accessionCmd)
82
82
accessionCmd.Flags().BoolVar(&dryRun, "dry-run", false, "Toggles dry-run mode. Dry run will not run any state changing API calls")
83
-
accessionCmd.Flags().StringVar(&configPath, "config", "config.yaml", "Path to configuration file")
84
-
accessionCmd.Flags().StringVar(&dataDirectory, "data-directory", "data", "Path to directory to write / read intermediate files for stableIDs and fileIDs")
83
+
accessionCmd.Flags().StringVarP(&configPath, "config", "c", "config.yaml", "Path to configuration file")
84
+
accessionCmd.Flags().StringVarP(&dataDirectory, "data-directory", "d", "data", "Path to directory to write / read intermediate files for stableIDs and fileIDs")
Copy file name to clipboardExpand all lines: internal/dataset/dataset.go
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -80,8 +80,8 @@ var datasetCmd = &cobra.Command{
80
80
funcinit() {
81
81
cmd.AddCommand(datasetCmd)
82
82
datasetCmd.Flags().BoolVar(&dryRun, "dry-run", false, "Toggles dry-run mode. Dry run will not run any state changing API calls")
83
-
datasetCmd.Flags().StringVar(&configPath, "config", "config.yaml", "Path to configuration file")
84
-
datasetCmd.Flags().StringVar(&dataDirectory, "data-directory", "data", "Path to directory to write / read intermediate files for stableIDs and fileIDs")
83
+
datasetCmd.Flags().StringVarP(&configPath, "config", "c", "config.yaml", "Path to configuration file")
84
+
datasetCmd.Flags().StringVarP(&dataDirectory, "data-directory", "d", "data", "Path to directory to write / read intermediate files for stableIDs and fileIDs")
Copy file name to clipboardExpand all lines: internal/mail/mail.go
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -43,8 +43,8 @@ var mailCmd = &cobra.Command{
43
43
funcinit() {
44
44
cmd.AddCommand(mailCmd)
45
45
mailCmd.Flags().BoolVar(&dryRun, "dry-run", false, "Toggles dry-run mode. Dry run will send all emails to the address in configuration.Email (env or yaml conf)")
46
-
mailCmd.Flags().StringVar(&configPath, "config", "config.yaml", "Path to configuration file")
47
-
mailCmd.Flags().StringVar(&dataDirectory, "data-directory", "data", "Directory to retrieve files from to attach in mail notifications")
46
+
mailCmd.Flags().StringVarP(&configPath, "config", "c", "config.yaml", "Path to configuration file")
47
+
mailCmd.Flags().StringVarP(&dataDirectory, "data-directory", "d", "data", "Directory to retrieve files from to attach in mail notifications")
0 commit comments