Skip to content

Commit 83610e6

Browse files
Johannes HötterJohannes Hötter
authored andcommitted
improve docs
1 parent c587b02 commit 83610e6

File tree

4 files changed

+50
-28
lines changed

4 files changed

+50
-28
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,29 @@ password = "your-password"
2121
project_id = "your-project-id" # can be found in the URL of the web application
2222

2323
client = Client(username, password, project_id)
24-
# if you run the application locally, please the following instead:
24+
# if you run the application locally, please use the following instead:
2525
# client = Client(username, password, project_id, uri="http://localhost:4455")
2626
```
2727

28-
Alternatively, you can provide a `secrets.json` file in your repository, looking as follows:
28+
Alternatively, you can provide a `secrets.json` file in your directory where you want to run the SDK, looking as follows:
2929
```json
3030
{
3131
"user_name": "your-username",
3232
"password": "your-password",
3333
"project_id": "your-project-id"
3434
}
3535
```
36-
Again, if you run on your local machine, you should provide also `"uri": "http://localhost:4455"`.
36+
Again, if you run on your local machine, you should also provide `"uri": "http://localhost:4455"`. Afterwards, you can access the client like this:
37+
```python
38+
client = Client.from_secrets_file("secrets.json")
39+
```
3740

3841
Now, you can easily fetch the data from your project:
3942
```python
4043
df = client.get_record_export()
4144
```
4245

43-
Alternatively, you can also just run `kern pull` in your CLI given that you have provided the `secrets.json` file.
46+
Alternatively, you can also just run `kern pull` in your CLI given that you have provided the `secrets.json` file in the same directory.
4447

4548
The `df` contains data of the following scheme:
4649
- all your record attributes are stored as columns, e.g. `headline` or `running_id` if you uploaded records like `{"headline": "some text", "running_id": 1234}`

cli.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

kern/cli.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from kern import Client
2+
import sys
3+
from wasabi import msg
4+
5+
6+
def pull():
7+
client = Client.from_secrets_file("secrets.json")
8+
project_name = client.get_project_details()["name"]
9+
download_to = f"{project_name}.json"
10+
client.get_record_export(download_to=download_to)
11+
12+
13+
def help():
14+
msg.info(
15+
"With the Kern SDK, you can type commands as `kern <command>`. Currently, we provide the following:"
16+
)
17+
msg.info(
18+
"- kern pull: Download the record export of the project defined in `settings.json` to your local storage."
19+
)
20+
msg.info(
21+
"- kern push <path>: Upload a record file to the project defined in `settings.json` from your local storage. Currently in development."
22+
)
23+
24+
25+
def main():
26+
cli_args = sys.argv[1:]
27+
if len(cli_args) == 0:
28+
msg.fail(
29+
"Please provide some arguments when running kern. Type `kern help` for some instructions."
30+
)
31+
else:
32+
command = cli_args[0]
33+
if command == "pull":
34+
pull()
35+
elif command == "push":
36+
msg.warn("Currently in development.")
37+
elif command == "help":
38+
help()
39+
else:
40+
msg.fail(
41+
f"Could not understand command `{command}`. Type `kern help` for some instructions."
42+
)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
],
4747
entry_points={
4848
"console_scripts": [
49-
"kern=cli:main",
49+
"kern=kern.cli:main",
5050
],
5151
},
5252
)

0 commit comments

Comments
 (0)