Skip to content

Commit

Permalink
fix: addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniAkash committed May 2, 2024
1 parent 2f732dc commit fd1c824
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/client/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import {
Input as GrpcInput,
Image,
Point,
Polygon,
Region,
RegionInfo,
Text,
Video,
} from "clarifai-nodejs-grpc/proto/clarifai/api/resources_pb";
import { AuthConfig } from "../utils/types";
import { AuthConfig, Polygon } from "../utils/types";
import { Lister } from "./lister";
import { Buffer } from "buffer";
import fs from "fs";
Expand Down Expand Up @@ -739,9 +738,9 @@ export class Input extends Lister {
}: {
inputId: string;
label: string;
polygons: number[][][];
polygons: Polygon[];
}): Annotation {
const polygonsSchema = z.array(z.array(z.array(z.number())));
const polygonsSchema = z.array(z.array(z.tuple([z.number(), z.number()])));
try {
polygonsSchema.parse(polygons);
} catch {
Expand Down
3 changes: 2 additions & 1 deletion src/datasets/upload/features.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { JavaScriptValue } from "google-protobuf/google/protobuf/struct_pb";
import { Polygon } from "../../utils/types";

export interface TextFeatures {
imagePath?: undefined;
Expand Down Expand Up @@ -33,7 +34,7 @@ export interface VisualDetectionFeatures {
export interface VisualSegmentationFeatures {
imagePath: string;
labels: Array<string | number>;
polygons: Array<Array<Array<number>>>;
polygons: Polygon[];
geoInfo?: [number, number];
id?: number;
metadata?: Record<string, JavaScriptValue>;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function mergeObjects(obj1: AuthConfig, obj2: AuthConfig): AuthConfig {
export class BackoffIterator {
private count: number;

constructor({ count = 0 }: { count?: number } = { count: 0 }) {
constructor({ count } = { count: 0 }) {
this.count = count;
}

Expand Down
3 changes: 3 additions & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ export type GrpcWithCallback<TRequest, TResponse> = (
export type PaginationRequestParams<T extends Record<string, unknown>> =
| Omit<Partial<T>, "userAppId" | "pageNo" | "perPage">
| Record<string, never>;

export type Point = [number, number];
export type Polygon = Array<Point>;

0 comments on commit fd1c824

Please sign in to comment.