-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.qmd
72 lines (55 loc) · 1.26 KB
/
README.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
execute:
# Seemingly the only way to suppress the parameters being printed
echo: false
format: "gfm"
---
```{python}
#| tags: [parameters]
#| output: false
#| echo: false
board = None
api_key = None
```
# mondantic
Converts from Monday.com boards to Pydantic dataclasses.
## Installation
```bash
pip install git+https://github.com/WEHI-ResearchComputing/mondantic.git
```
## Usage
Let's say we're working with the following demo board:

### Schema Generation
The first step is to generate the Pydantic schema.
This is most easily done using the CLI:
```{python}
#| output: false
#| echo: true
! mondantic-codegen --board-id "{board}" --api-key "{api_key}" > models.py
```
Which generates:
```{python}
#| echo: false
from IPython.display import Markdown, display
with open("models.py") as fp:
display(Markdown(f"```python\n{fp.read()}\n```"))
```
```{python}
#| echo: false
#| output: true
%run models.py
```
## Hydration
Then, you can create instances of these models in Python.
Note that each column contains nested data classes, hence the long output!
```{python}
#| echo: false
```
```{python}
#| echo: true
from mondantic import hydrate
from devtools import pprint
for instance in hydrate(TestBoard, api_key):
pprint(instance)
```