|
1 | 1 | # Data `BlobEntry=>Blob` |
2 | 2 |
|
3 | | -## Getting BlobEntries |
| 3 | +Many `BlobEntry`s from various location can all reference the same large and heavy binary data `Blob`. Furthermore, this system allows a distributed usage over a large networked system. |
4 | 4 |
|
5 | | -Additional (large) data attached to variables exist in a few different ways. The primary method for storing additional large data blobs with a variable, is to look at the `BlobEntry`s associated with a particular variable. For example: |
| 5 | +:::{tip} |
| 6 | +`Blob`s are separate from `BlobEntry`s. Various nodes on the graph can have any number of `BlobEntry`s (including duplicates), but the user does not necessary have the need to pull the bandwidth heavy blobs across all parts of the system network. |
| 7 | +::: |
| 8 | + |
| 9 | +## What is a `BlobEntry` |
| 10 | + |
| 11 | +Additional (large) data attached to variables exist in a few different ways. The primary method for storing additional large data as a `Blob`, however, a blob just "barcoded" binary blob. we use `BlobEntry`s to organize, find, share, distribute, make available and useful across the divergent network how a `Blob` is associated with the graph. |
| 12 | + |
| 13 | +A blob entry is small about of structed data that holds reference information to find an actual binary blob which is possibly a massive amount of data. |
| 14 | + |
| 15 | +### Listing BlobEntries on a Node |
| 16 | + |
| 17 | +The `list` verb is purposefully limited to just returning a list of labels (i.e. `List[string]`), and therefore the following call only returns the labels of `BlobEntry`s attached a particular node (variable, session, robot, etc.): |
6 | 18 | ```python |
7 | | -entries = await listBlobEntries(client, context, "x0") |> fetch |
| 19 | +ent_labels = listBlobEntries(fgclient, 'x0') |
| 20 | +# ent_labels = await listBlobEntriesAsync(fgclient, 'x0') |
| 21 | + |
8 | 22 | # human friendly labels |
9 | | -print([en.label for en in entries]) |
10 | | -# e.g. ['Camera0', 'UserCalib', 'GPS', 'JoystickCmds'] |
| 23 | +print('Human friendly BlobEntry labels on x0 are', ent_labels) |
| 24 | +# e.g. ['LEFTCAM_1002', 'LEFTCAM_1003', 'UserCalib', 'GPS', 'JoystickCmds'] |
| 25 | +``` |
11 | 26 |
|
12 | | -# machine friendly system wide unique identifier |
13 | | -print([en.id for en in entries]) |
| 27 | +```{eval-rst} |
| 28 | +.. autofunction:: navability.services.listBlobEntries |
| 29 | +.. autofunction:: navability.services.listBlobEntriesAsync |
14 | 30 | ``` |
15 | 31 |
|
16 | | -:::{tip} |
17 | | -`Blob`s are separate from `BlobEntry`s. Various nodes on the graph can have any number of `BlobEntry`s (including duplicates), but the user does not necessary have the need to pull the bandwidth heavy blobs across all parts of the system network. |
18 | | -::: |
| 32 | +### Getting a `BlobEntry` |
| 33 | + |
| 34 | +Using the human friendly label from the `listBlobEntries` above, we can fetch the `BlobEntry` |
| 35 | +```python |
| 36 | +entry = getBlobEntry(fgclient, 'LEFTCAM_1002') |
| 37 | +# entry = await getBlobEntryAsync(fgclient, 'LEFTCAM_1002') |
| 38 | +``` |
| 39 | + |
| 40 | +The entry object is well structured |
| 41 | +```{eval-rst} |
| 42 | +.. autoclass:: navability.entities.BlobEntry |
| 43 | +``` |
19 | 44 |
|
20 | | -Data blobs can be fetched via, e.g. using the unique `id` (or `blobId`) of from a `BlobEntry`: |
| 45 | +## Getting the associated `Blob` |
| 46 | + |
| 47 | +A binary `Blob` is basically just a "barcoded" piece of data that can be associated (via individual `BlobEntry`s) multiple times across multiple graph nodes, sessions, or robots. |
| 48 | + |
| 49 | +Data blobs can be fetched via, e.g. using the unique `.blobId` as primary (or `.originId` as secondary) reference. Also note that the blob itself may also be replicated across any number of blob stores, depending on the application: |
21 | 50 | ```python |
22 | | -blob = await getBlob(client, context, entries[1].id]; checkhash=false) |
23 | | -# b'{"latitude":41.7325,"altitude":2.211,"header":{"stamp":{"secs":1670378554,"nsecs":000624417},"seq":91,"frame_id":"gps","_type":"ROS1/std_msgs/Header"},"status":{"status":0,"service":1},"position_covariance":[0.265225,0.0,0.0,0.0,0.265225,0.0,0.0,0.0,0.556516],"longitude":-49.946944,"_type":"ROS1/sensor_msgs/NavSatFix","position_covariance_type":2}' |
| 51 | +blob = getBlob(fgclient, entry.blobId]; checkhash=false) # legacy versions did not use .hash check |
| 52 | +# blob = await getBlobAsync(fgclient, entry.blobId]; checkhash=false) |
24 | 53 | ``` |
25 | 54 |
|
26 | | -Data blobs are provided in binary format. A blob can be associated via any number of `BlobEntry`s across multiple graph nodes, sessions, or robots. `BlobEntry` also stores a hash value to ensure data consistency which must correspond to the stored hash upon retrieval. The check can be skipped as indicated by the option in the function call above. |
| 55 | +The blob contains binary information, for example this `mimeType = application/octet-stream/json; _type=ROS.sensor_msgs.NavSatFix`: |
| 56 | +``` |
| 57 | +b'{"latitude":41.7325,"altitude":2.211,"header":{"stamp":{"secs":1670378554,"nsecs":000624417},"seq":91,"frame_id":"gps","_type":"ROS1/std_msgs/Header"},"status":{"status":0,"service":1},"position_covariance":[0.265225,0.0,0.0,0.0,0.265225,0.0,0.0,0.0,0.556516],"longitude":-49.946944,"_type":"ROS1/sensor_msgs/NavSatFix","position_covariance_type":2}' |
| 58 | +``` |
27 | 59 |
|
| 60 | +:::{tip} |
| 61 | +Depending on the blob store, it may also be possible to retrieve a blob using the `.originId` rather than `.blobId`. |
| 62 | +::: |
28 | 63 |
|
29 | 64 | :::{tip} |
30 | 65 | A blob is owned by a `user` and only accessible by other users if allowed via approved roles or permissions. |
31 | 66 | ::: |
32 | 67 |
|
33 | 68 | :::{tip} |
34 | | -All `blobId`s are unique across the entire distributed system and are immutable. |
| 69 | +`BlobEntry.hash` helps ensure data consistency by rehasing the retrieved blob binary data itself. |
35 | 70 | ::: |
36 | 71 |
|
37 | 72 | ## Adding BlobEntries |
38 | 73 |
|
39 | | -Blobs can be linked to any variable (future node) in the graph. This is easily done by adding a BlobEntry: |
40 | | -```python |
41 | | -res = await addBlobEntry(client, context, 'x12', entries[1].id, entries[1].label, len(blob), entries[1].mimeType) |
42 | | -``` |
43 | | - |
44 | | -:::{tip} |
45 | | -More ubiqitous use of `blob` size was recently introduced to `BlobEntry` and will be unified with less user input as part of SDKs v0.6 upgrades. |
| 74 | +:::{warning} |
| 75 | +Adding `Blob` or `BlobEntry`s from the Python SDK are under construction and expected to be part of the v0.6.1 release. This functionality has already been released with the JuliaLang SDK. |
46 | 76 | ::: |
47 | 77 |
|
48 | | -## BlobEntry Structure |
49 | | - |
50 | | -To simplify many different requirements, a `BlobEntry` has the following field structure: |
51 | | -``` |
52 | | -{ |
53 | | - id: UUID |
54 | | - label: string |
55 | | - description: string |
56 | | - blobstore: string |
57 | | - hash: string |
58 | | - mimeType: string |
59 | | - origin: string |
60 | | -
|
61 | | - ## planned future fields |
62 | | - # blobId: UUID |
63 | | - # originId: UUID |
64 | | - # createdTimestamp: datetime |
65 | | - # size: int |
66 | | - # metadata: string |
67 | | -} |
| 78 | +Blobs can be linked to any variable (future node) in the graph. This is easily done by adding a BlobEntry: |
| 79 | +```python |
| 80 | +res = addBlobEntry(fgclient, 'x12', entries[1].id, entries[1].label, len(blob), entries[1].mimeType) |
| 81 | +# res = await addBlobEntryAsync(fgclient, 'x12', entries[1].id, entries[1].label, len(blob), entries[1].mimeType) |
68 | 82 | ``` |
69 | 83 |
|
70 | 84 | ## Adding New Blobs |
71 | 85 |
|
72 | 86 | It is also possible to push data blobs: |
73 | 87 | ```python |
74 | | -blobId = await addBlob(client, "testimage.png", imgblob) |
| 88 | +client = NavAbilityHttpsClient() |
| 89 | +blobId = await addBlob(fgclient.client, "testimage.png", imgblob) |
75 | 90 | ``` |
76 | 91 |
|
77 | 92 | Remember to add at least one BlobEntry somewhere in your session so that you might find it again in the future, see `addBlobEntry` above. |
78 | 93 |
|
| 94 | +:::{eval-rst} |
| 95 | +.. autofunction:: navability.entities.NavAbilityHttpsClient |
| 96 | +::: |
| 97 | + |
79 | 98 | :::{seealso} |
80 | 99 | See [Tutorial 5 from ICRA 2022 for a more in-depth example of working with data blobs](sdkpynb:python/navability-sdk/icra-5-marineexample). |
81 | 100 | ::: |
82 | | - |
83 | | -<!-- ```@docs |
84 | | -listBlobEntries |
85 | | -getBlob |
86 | | -``` --> |
|
0 commit comments