Skip to content

Commit

Permalink
doc about import/export
Browse files Browse the repository at this point in the history
  • Loading branch information
ebrehault committed Sep 28, 2023
1 parent 64ca5b0 commit fb63776
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


- Return RID on upload
- Support KB import/export


## 1.1.12 (2023-09-21)
Expand Down
1 change: 1 addition & 0 deletions docs/01-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ First steps should be:
- [Upload conversation](07-conversation.md)
- [Search](06-search.md)
- [Extract information from a file](05-extract.md)
- [Import/export knowledge boxes](08-import-export.md)
- Detect Entities
- [Get embedding from text](05-extract.md)
- Get answer from a context
52 changes: 52 additions & 0 deletions docs/08-import-export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Import/export

## Export a kb

```sh
nuclia kbs my-source-kb default
nuclia kb exports start --path=/some/path/foobar

> Export is ready to be downloaded.
> Downloading export 8be5339818f443f8b6c0afc143d2fe02 to /some/path/foobar: 7.13MB [00:05, 1.36MB/s]
```

## Import it to another kb

```sh
nuclia kbs my-dst-kb default
nuclia kb imports start --path=/some/path/foobar

> Uploading from /some/path/foobar to import: 7.13MB [00:01, 3.77MB/s]
> import_id='317e6816a661450e91ba192afad96b99'
```

The returned `import_id` can be used to check the status of the import:

```sh
nuclia kb imports status --import_id=317e6816a661450e91ba192afad96b99

> status=<Status.FINISHED: 'finished'>
```

Alternately, you can start import and use `--sync`, so the command waits for it to finish:

```sh
nuclia kb imports start --path=/some/path/foobar --sync
```

## Using the SDK

```python
from nuclia import sdk

exports = sdk.NucliaExports()
export_id = exports.start().export_id
assert exports.status(export_id=export_id).value == "finished"
exports.download(export_id=export_id, path="/some/path/kb.export")

imports = sdk.NucliaImports()
import_id = imports.start(path="/some/path/kb.export").import_id
assert imports.status(import_id=import_id).status == "finished"

imports.start(path="/some/path/kb.export", sync=True)
```

0 comments on commit fb63776

Please sign in to comment.