Skip to content

Commit 5ce895c

Browse files
viambotgithub-actions[bot]
authored andcommitted
[WORKFLOW] AI update based on proto changes from commit f7cb07e
1 parent 77c30d9 commit 5ce895c

File tree

4 files changed

+131
-2
lines changed

4 files changed

+131
-2
lines changed

src/app/data-client.spec.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import {
7272
DataCaptureUploadRequest,
7373
DataCaptureUploadResponse,
7474
DataType,
75+
MimeType,
7576
SensorData,
7677
SensorMetadata,
7778
UploadMetadata,
@@ -93,10 +94,19 @@ import {
9394
ListDataPipelineRunsResponse,
9495
} from '../gen/app/datapipelines/v1/data_pipelines_pb';
9596
import { DataPipelinesService } from '../gen/app/datapipelines/v1/data_pipelines_connect';
97+
import { DataManagerService } from '../gen/service/datamanager/v1/data_manager_connect';
98+
import {
99+
UploadBinaryDataToDatasetsRequest,
100+
UploadBinaryDataToDatasetsResponse,
101+
} from '../gen/service/datamanager/v1/data_manager_pb';
102+
import { DataManagerClient } from '../services/data-manager/client';
103+
96104
vi.mock('../gen/app/data/v1/data_pb_service');
97105

98106
let mockTransport: Transport;
99107
const subject = () => new DataClient(mockTransport);
108+
const dataManagerSubject = () =>
109+
new DataManagerClient({} as any, 'data_manager', {}); // Mock RobotClient
100110

101111
describe('DataClient tests', () => {
102112
const filter = subject().createFilter({
@@ -1716,3 +1726,46 @@ describe('DataPipelineClient tests', () => {
17161726
});
17171727
});
17181728
});
1729+
1730+
describe('DataManagerClient tests', () => {
1731+
const name = 'data_manager';
1732+
const binaryData = new Uint8Array([1, 2, 3]);
1733+
const tags = ['tag1', 'tag2'];
1734+
const datasetIds = ['dataset1', 'dataset2'];
1735+
const mimeType = MimeType.MIME_TYPE_JPEG;
1736+
const extra = { key: 'value' };
1737+
1738+
describe('uploadBinaryDataToDatasets', () => {
1739+
let capReq: UploadBinaryDataToDatasetsRequest;
1740+
beforeEach(() => {
1741+
mockTransport = createRouterTransport(({ service }) => {
1742+
service(DataManagerService, {
1743+
uploadBinaryDataToDatasets: (req) => {
1744+
capReq = req;
1745+
return new UploadBinaryDataToDatasetsResponse();
1746+
},
1747+
});
1748+
});
1749+
});
1750+
1751+
it('uploads binary data to datasets', async () => {
1752+
const expectedRequest = new UploadBinaryDataToDatasetsRequest({
1753+
name,
1754+
binaryData,
1755+
tags,
1756+
datasetIds,
1757+
mimeType,
1758+
extra: Struct.fromJson(extra),
1759+
});
1760+
1761+
await dataManagerSubject().uploadBinaryDataToDatasets(
1762+
binaryData,
1763+
tags,
1764+
datasetIds,
1765+
mimeType,
1766+
extra
1767+
);
1768+
expect(capReq).toStrictEqual(expectedRequest);
1769+
});
1770+
});
1771+
});

src/app/data-client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ export class DataClient {
604604
* @param tags The tags to add to the data
605605
* @param filter Optional `pb.Filter` specifying binary data to add tags to.
606606
* No `filter` implies all binary data.
607+
* @deprecated
607608
*/
608609
async addTagsToBinaryDataByFilter(tags: string[], filter?: Filter) {
609610
await this.dataClient.addTagsToBinaryDataByFilter({
@@ -679,6 +680,7 @@ export class DataClient {
679680
* @param filter Optional `pb.Filter` specifying binary data to add tags to.
680681
* No `filter` implies all binary data.
681682
* @returns The number of items deleted
683+
* @deprecated
682684
*/
683685
async removeTagsFromBinaryDataByFilter(tags: string[], filter?: Filter) {
684686
const resp = await this.dataClient.removeTagsFromBinaryDataByFilter({
@@ -705,6 +707,7 @@ export class DataClient {
705707
* @param filter Optional `pb.Filter` specifying what data to get tags from.
706708
* No `filter` implies all data.
707709
* @returns The list of tags
710+
* @deprecated
708711
*/
709712
async tagsByFilter(filter?: Filter) {
710713
const resp = await this.dataClient.tagsByFilter({ filter });
@@ -826,6 +829,7 @@ export class DataClient {
826829
* @param filter Optional `pb.Filter` specifying what data to get tags from.
827830
* No `filter` implies all labels.
828831
* @returns The list of bounding box labels
832+
* @deprecated
829833
*/
830834
async boundingBoxLabelsByFilter(filter?: Filter) {
831835
const resp = await this.dataClient.boundingBoxLabelsByFilter({

src/services/data-manager/client.ts

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { Struct, type JsonValue } from '@bufbuild/protobuf';
22
import type { CallOptions, PromiseClient } from '@connectrpc/connect';
33
import { DataManagerService } from '../../gen/service/datamanager/v1/data_manager_connect.js';
4-
import { SyncRequest } from '../../gen/service/datamanager/v1/data_manager_pb.js';
4+
import {
5+
SyncRequest,
6+
UploadBinaryDataToDatasetsRequest,
7+
} from '../../gen/service/datamanager/v1/data_manager_pb.js';
58
import type { RobotClient } from '../../robot';
69
import type { Options } from '../../types';
710
import { doCommandFromClient } from '../../utils';
811
import type { DataManager } from './data-manager';
12+
import { MimeType } from '../../app/datasync/v1/data_sync_pb.js';
913

1014
export class DataManagerClient implements DataManager {
1115
private client: PromiseClient<typeof DataManagerService>;
@@ -80,4 +84,55 @@ export class DataManagerClient implements DataManager {
8084
callOptions
8185
);
8286
}
83-
}
87+
88+
/**
89+
* Uploads binary data to specified datasets.
90+
*
91+
* @example
92+
*
93+
* ```ts
94+
* const dataManager = new VIAM.DataManagerClient(
95+
* machine,
96+
* 'my_data_manager'
97+
* );
98+
* const binaryData = new Uint8Array([1, 2, 3]);
99+
* const tags = ['tag1', 'tag2'];
100+
* const datasetIds = ['dataset1', 'dataset2'];
101+
* const mimeType = MimeType.MIME_TYPE_JPEG;
102+
* await dataManager.uploadBinaryDataToDatasets(
103+
* binaryData,
104+
* tags,
105+
* datasetIds,
106+
* mimeType
107+
* );
108+
* ```
109+
*
110+
* @param binaryData - The binary data to upload.
111+
* @param tags - Tags to associate with the binary data.
112+
* @param datasetIds - IDs of the datasets to upload the data to.
113+
* @param mimeType - The MIME type of the binary data.
114+
* @param extra - Additional arguments to pass to the method.
115+
* @param callOptions - Call options for the request.
116+
*/
117+
async uploadBinaryDataToDatasets(
118+
binaryData: Uint8Array,
119+
tags: string[],
120+
datasetIds: string[],
121+
mimeType: MimeType,
122+
extra = {},
123+
callOptions = this.callOptions
124+
) {
125+
const request = new UploadBinaryDataToDatasetsRequest({
126+
name: this.name,
127+
binaryData,
128+
tags,
129+
datasetIds,
130+
mimeType,
131+
extra: Struct.fromJson(extra),
132+
});
133+
134+
this.options.requestLogger?.(request);
135+
136+
await this.client.uploadBinaryDataToDatasets(request, callOptions);
137+
}
138+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
import type { Struct } from '@bufbuild/protobuf';
22
import type { Resource } from '../../types';
3+
import type { MimeType } from '../../app/datasync/v1/data_sync_pb.js';
34

45
export interface DataManager extends Resource {
56
sync: (extra?: Struct) => Promise<void>;
7+
/**
8+
* Uploads binary data to specified datasets.
9+
*
10+
* @param binaryData - The binary data to upload.
11+
* @param tags - Tags to associate with the binary data.
12+
* @param datasetIds - IDs of the datasets to upload the data to.
13+
* @param mimeType - The MIME type of the binary data.
14+
* @param extra - Additional arguments to pass to the method.
15+
*/
16+
uploadBinaryDataToDatasets: (
17+
binaryData: Uint8Array,
18+
tags: string[],
19+
datasetIds: string[],
20+
mimeType: MimeType,
21+
extra?: Struct
22+
) => Promise<void>;
623
}

0 commit comments

Comments
 (0)