2
2
title : " Functions and classes"
3
3
callout-icon : false
4
4
callout-appearance : " minimal"
5
+ toc-depth : 2
5
6
---
6
7
8
+ ``` {=html}
9
+ <style>
10
+ h3 {
11
+ font-size: 1.1em;
12
+ }
13
+ </style>
14
+ ```
15
+
7
16
::: {.callout-important appearance="default" icon="true"}
8
17
We created this document mainly as a way to help us as a team all
9
18
understand and agree on what we're making and what needs to be worked
@@ -51,73 +60,58 @@ and resource(s) in the package. This metadata is stored in the
51
60
` datapackage.json ` file and follows the Frictionless Data specification.
52
61
53
62
::: {.callout-important appearance="default" icon="true"}
54
- Functions shown in orange are not yet implemented while those in blue
55
- are implemented.
63
+ Functions shown with a {{< var wip >}} icon are not yet implemented
64
+ while those with a {{< var done >}} icon are implemented.
56
65
:::
57
66
58
67
## Data package functions
59
68
60
- ::: {.callout-warning collapse="true"}
61
- ### ` create_package_properties(properties, path) `
69
+ ### {{< var wip >}} ` create_package_properties(properties, path) `
62
70
63
71
This is the first function to use to create a new data package. It
64
72
generates a template for the ` datapackage.json ` file where the user
65
73
needs to fill in required fields by providing the ` properties ` argument
66
74
using the helper ` PackageProperties ` class. Outputs a full Properties
67
75
object. Use ` write_package_properties() ` to store the properties to the
68
76
` datapackage.json ` file.
69
- :::
70
77
71
- ::: {.callout-warning collapse="true"}
72
- ### ` build_readme_text(properties) `
78
+ ### {{< var wip >}} ` build_readme_text(properties) `
73
79
74
80
Using a template, this will build a README file with the contents of the
75
81
properties object in a human-readable format. Outputs a text string. Use
76
82
` write_text() ` to save the text to the ` README.md ` file.
77
- :::
78
83
79
- ::: {.callout-note collapse="true"}
80
- ### ` edit_package_properties(path, properties) `
84
+ ### {{< var done >}} ` edit_package_properties(path, properties) `
81
85
82
86
See the help documentation with ` help(edit_package_properties()) ` for
83
87
more details.
84
- :::
85
88
86
- ::: {.callout-warning collapse="true"}
87
- ### ` delete_package(path, confirm) `
89
+ ### {{< var wip >}} ` delete_package(path, confirm) `
88
90
89
91
Completely delete a specific package and all it's data resources.
90
92
Because this action would be permanent, the ` confirm ` argument would
91
93
default to ` false ` so that the user needs to explicitly provide ` true `
92
94
to the function argument as confirmation. This is done to prevent
93
95
accidental deletion. Outputs ` true ` if the deletion was successful.
94
- :::
95
96
96
- ::: {.callout-note collapse="true"}
97
- ### ` write_package_properties(properties, path) `
97
+ ### {{< var done >}} ` write_package_properties(properties, path) `
98
98
99
- See the help documentation with ` help(write_package_properties) ` for more
100
- details.
101
- :::
99
+ See the help documentation with ` help(write_package_properties) ` for
100
+ more details.
102
101
103
102
## Data resource functions
104
103
105
- ::: {.callout-note collapse="true"}
106
- ### ` create_resource_structure(path) `
104
+ ### {{< var done >}}` create_resource_structure(path) `
107
105
108
- See the help documentation with ` help(create_resource_structure) ` for more
109
- details.
110
- :::
106
+ See the help documentation with ` help(create_resource_structure) ` for
107
+ more details.
111
108
112
- ::: {.callout-note collapse="true"}
113
- ### ` create_resource_properties(path, properties) `
109
+ ### {{< var done >}} ` create_resource_properties(path, properties) `
114
110
115
- see the help documentation with ` help(create_resource_properties) ` for more
116
- details.
117
- :::
111
+ See the help documentation with ` help(create_resource_properties) ` for
112
+ more details.
118
113
119
- ::: {.callout-warning collapse="true"}
120
- ### ` write_resource_data_to_raw(data_path, resource_properties) `
114
+ ### {{< var wip >}} ` write_resource_data_to_raw(data_path, resource_properties) `
121
115
122
116
See the help documentation with ` help(write_resource_data_to_raw) ` for
123
117
more details.
@@ -132,31 +126,25 @@ flowchart
132
126
in_properties --> function
133
127
function --> out
134
128
```
135
- :::
136
129
137
- ::: {.callout-warning collapse="true"}
138
- ### ` write_resource_parquet(raw_files, path) `
130
+ ### {{< var wip >}} ` write_resource_parquet(raw_files, path) `
139
131
140
132
This function takes the files provided by ` raw_files ` and merges them
141
133
into a ` data.parquet ` file provided by ` path ` . Use
142
134
` path_resource_data() ` to provide the correct path location for ` path `
143
135
and ` path_resource_raw_files() ` for the ` raw_files ` argument. Outputs
144
136
the path object of the created file.
145
- :::
146
137
147
- ::: {.callout-warning collapse="true"}
148
- ### ` edit_resource_properties(path, properties) `
138
+ ### {{< var wip >}} ` edit_resource_properties(path, properties) `
149
139
150
140
Edit the properties of a resource in a package. The ` properties `
151
141
argument must be a JSON object that follows the Frictionless Data
152
142
specification. Use the ` path_properties() ` function to provide the
153
143
correct path location. Outputs a JSON object only; use
154
144
` write_resource_properties() ` to save the JSON object to the
155
145
` datapackage.json ` file.
156
- :::
157
146
158
- ::: {.callout-warning collapse="true"}
159
- ### ` delete_resource_raw_file(path, confirm) `
147
+ ### {{< var wip >}} ` delete_resource_raw_file(path, confirm) `
160
148
161
149
Use this to delete a raw file in the ` raw/ ` folder of a resource. This
162
150
is useful if the file is no longer needed or if it is incorrect or had
@@ -166,10 +154,8 @@ list of files found. Will only delete one file. The `confirm` argument
166
154
defaults to ` false ` so that the user needs to explicitly provide ` true `
167
155
to the function argument as confirmation. This is done to prevent
168
156
accidental deletion. Outputs ` true ` if the deletion was successful.
169
- :::
170
157
171
- ::: {.callout-warning collapse="true"}
172
- ### ` delete_resource_data(path, confirm) `
158
+ ### {{< var wip >}} ` delete_resource_data(path, confirm) `
173
159
174
160
Delete all data (Parquet) and raw data of a specific resource. Use
175
161
` path_resource_raw() ` to provide the correct path location. The
@@ -178,32 +164,25 @@ explicitly provide `true` to the function argument as confirmation. This
178
164
is done to prevent accidental deletion. Outputs ` true ` if the deletion
179
165
was successful. Use ` delete_resource_properties() ` to delete the the
180
166
associated properties/metadata for the resource.
181
- :::
182
167
183
- ::: {.callout-warning collapse="true"}
184
- ### ` delete_resource_properties(path, confirm) `
168
+ ### {{< var wip >}} ` delete_resource_properties(path, confirm) `
185
169
186
170
Deletes all properties for a resource within the ` datapackage.json `
187
171
file. Use ` path_properties() ` to provide the correct location for
188
172
` path ` . The ` confirm ` argument defaults to ` false ` so that the user
189
173
needs to explicitly provide ` true ` to the function argument as
190
174
confirmation. This is done to prevent accidental deletion. Outputs
191
175
` true ` if the deletion was successful.
192
- :::
193
176
194
- ::: {.callout-note collapse="true"}
195
- ### ` write_resource_properties(properties, path) `
177
+ ### {{< var done >}} ` write_resource_properties(properties, path) `
196
178
197
- See the help documentation with ` help(write_resource_properties) ` for more
198
- details.
199
- :::
179
+ See the help documentation with ` help(write_resource_properties) ` for
180
+ more details.
200
181
201
- ::: {.callout-note collapse="true"}
202
- ### ` extract_resource_properties(data_path) `
182
+ ### {{< var done >}} ` extract_resource_properties(data_path) `
203
183
204
- See the help documentation with ` help(extract_resource_properties) ` for more
205
- details.
206
- :::
184
+ See the help documentation with ` help(extract_resource_properties) ` for
185
+ more details.
207
186
208
187
## Path functions
209
188
@@ -213,45 +192,33 @@ details.
213
192
- If the wrong ` resource_id ` is given, an error message will include a
214
193
list of all the actual ` resource_id ` s for a specific package.
215
194
216
- ::: {.callout-note collapse="true"}
217
- ### ` path_properties(path) `
195
+ ### {{< var done >}} ` path_properties(path) `
218
196
219
197
See the help documentation with ` help(path_properties) ` for more
220
198
details.
221
- :::
222
199
223
- ::: {.callout-note collapse="true"}
224
- ### ` path_resources() `
200
+ ### {{< var done >}} ` path_resources() `
225
201
226
202
See the help documentation with ` help(path_resources) ` for more details.
227
- :::
228
203
229
- ::: {.callout-note collapse="true"}
230
- ### ` path_resource(resource_id) `
204
+ ### {{< var done >}} ` path_resource(resource_id) `
231
205
232
206
See the help documentation with ` help(path_resource) ` for more details.
233
- :::
234
207
235
- ::: {.callout-note collapse="true"}
236
- ### ` path_resource_raw(resource_id) `
208
+ ### {{< var done >}} ` path_resource_raw(resource_id) `
237
209
238
210
See the help documentation with ` help(path_resource_raw) ` for more
239
211
details.
240
- :::
241
212
242
- ::: {.callout-note collapse="true"}
243
- ### ` path_resource_raw_files(package_id, resource_id) `
213
+ ### {{< var done >}} ` path_resource_raw_files(package_id, resource_id) `
244
214
245
215
See the help documentation with ` help(path_resource_raw_files) ` for more
246
216
details.
247
- :::
248
217
249
- ::: {.callout-note collapse="true"}
250
- ### ` path_resource_data(package_id, resource_id) `
218
+ ### {{< var done >}} ` path_resource_data(package_id, resource_id) `
251
219
252
220
See the help documentation with ` help(path_resource_data) ` for more
253
221
details.
254
- :::
255
222
256
223
## Properties dataclasses
257
224
@@ -261,36 +228,28 @@ to allow us to pass structured properties objects between functions.
261
228
They also enable users to create valid properties objects more easily
262
229
and get an overview of optional and required class fields.
263
230
264
- ::: {.callout-note collapse="true"}
265
- ### ` PackageProperties `
231
+ ### {{< var done >}} ` PackageProperties `
266
232
267
233
See the help documentation with ` help(PackageProperties()) ` for more
268
234
details on the properties.
269
- :::
270
235
271
236
## Properties functions
272
237
273
- ::: {.callout-warning collapse="true"}
274
- ### ` read_properties(path) `
238
+ ### {{< var wip >}} ` read_properties(path) `
275
239
276
240
Reads the ` datapackage.json ` file, checks that is correct, and then
277
241
outputs a ` PackageProperties ` object.
278
- :::
279
242
280
243
## Helper functions
281
244
282
- ::: {.callout-warning collapse="true"}
283
- ### ` pretty_json(json) `
245
+ ### {{< var wip >}} ` pretty_json(json) `
284
246
285
247
Create a prettier, human readable version of a JSON object.
286
- :::
287
248
288
- ::: {.callout-warning collapse="true"}
289
- ### ` write_text(text, path) `
249
+ ### {{< var wip >}} ` write_text(text, path) `
290
250
291
251
Writes a text string to a file at the given path. Outputs the path
292
252
object of the created file.
293
- :::
294
253
295
254
## Observational unit functions
296
255
@@ -299,11 +258,9 @@ animal, event) that the data was collected on. An example would be: A
299
258
person in a research study who came to the clinic in May 2024 to have
300
259
their blood collected and to fill out a survey.
301
260
302
- ::: {.callout-warning collapse="true"}
303
- ### ` delete_participant_data() `
261
+ ### {{< var wip >}} ` delete_participant_data() `
304
262
305
263
TODO.
306
- :::
307
264
308
265
## Multi-user environments
309
266
@@ -315,21 +272,15 @@ All the below `path_*()` functions use `path_sprout_global()` internally
315
272
to get the global path as well as ` package_id ` and/or ` resource_id ` to
316
273
complete the correct path for the specific package/resource.
317
274
318
- ::: {.callout-note collapse="true"}
319
- ### ` path_packages() `
275
+ ### {{< var done >}} ` path_packages() `
320
276
321
277
See the help documentation with ` help(path_packages) ` for more details.
322
- :::
323
278
324
- ::: {.callout-note collapse="true"}
325
- ### ` path_package(package_id) `
279
+ ### {{< var done >}} ` path_package(package_id) `
326
280
327
281
See the help documentation with ` help(path_package) ` for more details.
328
- :::
329
282
330
- ::: {.callout-note collapse="true"}
331
- ### ` path_sprout_global() `
283
+ ### {{< var done >}} ` path_sprout_global() `
332
284
333
285
See the help documentation with ` help(path_sprout_global) ` for more
334
286
details.
335
- :::
0 commit comments