|
| 1 | +# Databus Client Python |
| 2 | + |
| 3 | +## Install |
| 4 | +```bash |
| 5 | +python3 -m pip install databusclient |
| 6 | +``` |
| 7 | + |
| 8 | +## CLI Usage |
| 9 | +```bash |
| 10 | +databusclient --help |
| 11 | +``` |
| 12 | + |
| 13 | +```man |
| 14 | +Usage: databusclient [OPTIONS] COMMAND [ARGS]... |
| 15 | +
|
| 16 | +Options: |
| 17 | + --install-completion [bash|zsh|fish|powershell|pwsh] |
| 18 | + Install completion for the specified shell. |
| 19 | + --show-completion [bash|zsh|fish|powershell|pwsh] |
| 20 | + Show completion for the specified shell, to |
| 21 | + copy it or customize the installation. |
| 22 | + --help Show this message and exit. |
| 23 | +
|
| 24 | +Commands: |
| 25 | + deploy |
| 26 | + downoad |
| 27 | +``` |
| 28 | +### Deploy command |
| 29 | +``` |
| 30 | +databusclient deploy --help |
| 31 | +``` |
| 32 | +``` |
| 33 | +
|
| 34 | +
|
| 35 | +Usage: databusclient deploy [OPTIONS] DISTRIBUTIONS... |
| 36 | +
|
| 37 | +Arguments: |
| 38 | + DISTRIBUTIONS... distributions in the form of List[URL|CV|fileext|compression|sha256sum:contentlength] where URL is the |
| 39 | + download URL and CV the key=value pairs (_ separted) |
| 40 | + content variants of a distribution, fileExt and Compression can be set, if not they are inferred from the path [required] |
| 41 | +
|
| 42 | +Options: |
| 43 | + --versionid TEXT target databus version/dataset identifier of the form <h |
| 44 | + ttps://databus.dbpedia.org/$ACCOUNT/$GROUP/$ARTIFACT/$VE |
| 45 | + RSION> [required] |
| 46 | + --title TEXT dataset title [required] |
| 47 | + --abstract TEXT dataset abstract max 200 chars [required] |
| 48 | + --description TEXT dataset description [required] |
| 49 | + --license TEXT license (see dalicc.net) [required] |
| 50 | + --apikey TEXT apikey [required] |
| 51 | + --help Show this message and exit. |
| 52 | +``` |
| 53 | +Examples of using deploy command |
| 54 | +``` |
| 55 | +databusclient deploy --versionid https://databus.dbpedia.org/user1/group1/artifact1/2022-05-18 --title title1 --abstract abstract1 --description description1 --license http://dalicc.net/licenselibrary/AdaptivePublicLicense10 --apikey MYSTERIOUS 'https://raw.githubusercontent.com/dbpedia/databus/master/server/app/api/swagger.yml|type=swagger' |
| 56 | +``` |
| 57 | + |
| 58 | +``` |
| 59 | +databusclient deploy --versionid https://dev.databus.dbpedia.org/denis/group1/artifact1/2022-05-18 --title "Client Testing" --abstract "Testing the client...." --description "Testing the client...." --license http://dalicc.net/licenselibrary/AdaptivePublicLicense10 --apikey MYSTERIOUS 'https://raw.githubusercontent.com/dbpedia/databus/master/server/app/api/swagger.yml|type=swagger' |
| 60 | +``` |
| 61 | + |
| 62 | +A few more notes for CLI usage: |
| 63 | + |
| 64 | +* The content variants can be left out ONLY IF there is just one distribution |
| 65 | + * For complete inferred: Just use the URL with `https://raw.githubusercontent.com/dbpedia/databus/master/server/app/api/swagger.yml` |
| 66 | + * If other parameters are used, you need to leave them empty like `https://raw.githubusercontent.com/dbpedia/databus/master/server/app/api/swagger.yml||yml|7a751b6dd5eb8d73d97793c3c564c71ab7b565fa4ba619e4a8fd05a6f80ff653:367116` |
| 67 | + |
| 68 | +## Module Usage |
| 69 | + |
| 70 | +### Step 1: Create lists of distributions for the dataset |
| 71 | + |
| 72 | +```python |
| 73 | +from databusclient import create_distribution |
| 74 | + |
| 75 | +# create a list |
| 76 | +distributions = [] |
| 77 | + |
| 78 | +# minimal requirements |
| 79 | +# compression and filetype will be inferred from the path |
| 80 | +# this will trigger the download of the file to evaluate the shasum and content length |
| 81 | +distributions.append( |
| 82 | + create_distribution(url="https://raw.githubusercontent.com/dbpedia/databus/master/server/app/api/swagger.yml", cvs={"type": "swagger"}) |
| 83 | +) |
| 84 | + |
| 85 | +# full parameters |
| 86 | +# will just place parameters correctly, nothing will be downloaded or inferred |
| 87 | +distributions.append( |
| 88 | + create_distribution( |
| 89 | + url="https://example.org/some/random/file.csv.bz2", |
| 90 | + cvs={"type": "example", "realfile": "false"}, |
| 91 | + file_format="csv", |
| 92 | + compression="bz2", |
| 93 | + sha256_length_tuple=("7a751b6dd5eb8d73d97793c3c564c71ab7b565fa4ba619e4a8fd05a6f80ff653", 367116) |
| 94 | + ) |
| 95 | +) |
| 96 | +``` |
| 97 | + |
| 98 | +A few notes: |
| 99 | + |
| 100 | +* The dict for content variants can be empty ONLY IF there is just one distribution |
| 101 | +* There can be no compression if there is no file format |
| 102 | + |
| 103 | +### Step 2: Create dataset |
| 104 | + |
| 105 | +```python |
| 106 | +from databusclient import create_dataset |
| 107 | + |
| 108 | +# minimal way |
| 109 | +dataset = create_dataset( |
| 110 | + version_id="https://dev.databus.dbpedia.org/denis/group1/artifact1/2022-05-18", |
| 111 | + title="Client Testing", |
| 112 | + abstract="Testing the client....", |
| 113 | + description="Testing the client....", |
| 114 | + license_url="http://dalicc.net/licenselibrary/AdaptivePublicLicense10", |
| 115 | + distributions=distributions, |
| 116 | +) |
| 117 | + |
| 118 | +# with group metadata |
| 119 | +dataset = create_dataset( |
| 120 | + version_id="https://dev.databus.dbpedia.org/denis/group1/artifact1/2022-05-18", |
| 121 | + title="Client Testing", |
| 122 | + abstract="Testing the client....", |
| 123 | + description="Testing the client....", |
| 124 | + license_url="http://dalicc.net/licenselibrary/AdaptivePublicLicense10", |
| 125 | + distributions=distributions, |
| 126 | + group_title="Title of group1", |
| 127 | + group_abstract="Abstract of group1", |
| 128 | + group_description="Description of group1" |
| 129 | +) |
| 130 | +``` |
| 131 | + |
| 132 | +NOTE: To be used you need to set all group parameters, or it will be ignored |
| 133 | + |
| 134 | +### Step 3: Deploy to databus |
| 135 | + |
| 136 | +```python |
| 137 | +from databusclient import deploy |
| 138 | + |
| 139 | +# to deploy something you just need the dataset from the previous step and an APIO key |
| 140 | +# API key can be found (or generated) at https://$$DATABUS_BASE$$/$$USER$$#settings |
| 141 | +deploy(dataset, "mysterious api key") |
| 142 | +``` |
0 commit comments