Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
isahers1 committed Dec 11, 2024
1 parent e8189ae commit 7b2e73d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 47 deletions.
20 changes: 7 additions & 13 deletions js/src/tests/client.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1425,9 +1425,9 @@ test("update examples multipart", async () => {
expect(attachmentData).toEqual(new Uint8Array(fs.readFileSync(pathname)));
attachmentData = updatedExample.attachments?.["bar"].presigned_url
? new Uint8Array(
(await fetch(
updatedExample.attachments?.["bar"].presigned_url
).then((res) => res.arrayBuffer())) as ArrayBuffer
(await fetch(updatedExample.attachments?.["bar"].presigned_url).then(
(res) => res.arrayBuffer()
)) as ArrayBuffer
)
: undefined;
expect(attachmentData).toEqual(new Uint8Array(fs.readFileSync(pathname)));
Expand All @@ -1443,11 +1443,8 @@ test("update examples multipart", async () => {
await client.updateExamplesMultipart(dataset.id, [exampleUpdate4]);
updatedExample = await client.readExample(exampleId);
expect(updatedExample.metadata).toEqual({ foo: "bar" });
expect(Object.keys(updatedExample.attachments ?? {})).toEqual([
"test_file2",
]);
attachmentData = updatedExample.attachments?.["test_file2"]
.presigned_url
expect(Object.keys(updatedExample.attachments ?? {})).toEqual(["test_file2"]);
attachmentData = updatedExample.attachments?.["test_file2"].presigned_url
? new Uint8Array(
(await fetch(
updatedExample.attachments?.["test_file2"].presigned_url
Expand All @@ -1471,11 +1468,8 @@ test("update examples multipart", async () => {
foo: "bar",
dataset_split: ["foo", "bar"],
});
expect(Object.keys(updatedExample.attachments ?? {})).toEqual([
"test_file",
]);
attachmentData = updatedExample.attachments?.["test_file"]
.presigned_url
expect(Object.keys(updatedExample.attachments ?? {})).toEqual(["test_file"]);
attachmentData = updatedExample.attachments?.["test_file"].presigned_url
? new Uint8Array(
(await fetch(
updatedExample.attachments?.["test_file"].presigned_url
Expand Down
63 changes: 29 additions & 34 deletions js/src/tests/evaluate_attachments.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ test("evaluate can handle examples with attachments", async () => {
"image"
].presigned_url
? new Uint8Array(
(await fetch(
config?.attachments?.["image"].presigned_url
).then((res) => res.arrayBuffer())) as ArrayBuffer
(await fetch(config?.attachments?.["image"].presigned_url).then(
(res) => res.arrayBuffer()
)) as ArrayBuffer
)
: undefined;
if (!arraysEqual(attachmentData ?? new Uint8Array(), expectedData)) {
Expand All @@ -61,12 +61,11 @@ test("evaluate can handle examples with attachments", async () => {
const expectedData = new Uint8Array(
Buffer.from("fake image data for testing")
);
const attachmentData: Uint8Array | undefined = attachments?.[
"image"
].presigned_url
const attachmentData: Uint8Array | undefined = attachments?.["image"]
.presigned_url
? new Uint8Array(
(await fetch(attachments?.["image"].presigned_url).then(
(res) => res.arrayBuffer()
(await fetch(attachments?.["image"].presigned_url).then((res) =>
res.arrayBuffer()
)) as ArrayBuffer
)
: undefined;
Expand Down Expand Up @@ -139,12 +138,11 @@ test("evaluate with attachments not in target function", async () => {
const expectedData = new Uint8Array(
Buffer.from("fake image data for testing")
);
const attachmentData: Uint8Array | undefined = attachments?.[
"image"
].presigned_url
const attachmentData: Uint8Array | undefined = attachments?.["image"]
.presigned_url
? new Uint8Array(
(await fetch(attachments?.["image"].presigned_url).then(
(res) => res.arrayBuffer()
(await fetch(attachments?.["image"].presigned_url).then((res) =>
res.arrayBuffer()
)) as ArrayBuffer
)
: undefined;
Expand Down Expand Up @@ -222,9 +220,9 @@ test("multiple evaluators with attachments", async () => {
"image"
].presigned_url
? new Uint8Array(
(await fetch(
config?.attachments?.["image"].presigned_url
).then((res) => res.arrayBuffer())) as ArrayBuffer
(await fetch(config?.attachments?.["image"].presigned_url).then(
(res) => res.arrayBuffer()
)) as ArrayBuffer
)
: undefined;
if (!arraysEqual(attachmentData ?? new Uint8Array(), expectedData)) {
Expand All @@ -239,12 +237,11 @@ test("multiple evaluators with attachments", async () => {
const expectedData = new Uint8Array(
Buffer.from("fake image data for testing")
);
const attachmentData: Uint8Array | undefined = attachments?.[
"image"
].presigned_url
const attachmentData: Uint8Array | undefined = attachments?.["image"]
.presigned_url
? new Uint8Array(
(await fetch(attachments?.["image"].presigned_url).then(
(res) => res.arrayBuffer()
(await fetch(attachments?.["image"].presigned_url).then((res) =>
res.arrayBuffer()
)) as ArrayBuffer
)
: undefined;
Expand All @@ -263,12 +260,11 @@ test("multiple evaluators with attachments", async () => {
const expectedData = new Uint8Array(
Buffer.from("fake image data for testing")
);
const attachmentData: Uint8Array | undefined = attachments?.[
"image"
].presigned_url
const attachmentData: Uint8Array | undefined = attachments?.["image"]
.presigned_url
? new Uint8Array(
(await fetch(attachments?.["image"].presigned_url).then(
(res) => res.arrayBuffer()
(await fetch(attachments?.["image"].presigned_url).then((res) =>
res.arrayBuffer()
)) as ArrayBuffer
)
: undefined;
Expand Down Expand Up @@ -343,9 +339,9 @@ test("evaluate with attachments runnable target function", async () => {
"image"
].presigned_url
? new Uint8Array(
(await fetch(
config?.attachments?.["image"].presigned_url
).then((res) => res.arrayBuffer())) as ArrayBuffer
(await fetch(config?.attachments?.["image"].presigned_url).then(
(res) => res.arrayBuffer()
)) as ArrayBuffer
)
: undefined;
if (!arraysEqual(attachmentData ?? new Uint8Array(), expectedData)) {
Expand All @@ -363,12 +359,11 @@ test("evaluate with attachments runnable target function", async () => {
const expectedData = new Uint8Array(
Buffer.from("fake image data for testing")
);
const attachmentData: Uint8Array | undefined = attachments?.[
"image"
].presigned_url
const attachmentData: Uint8Array | undefined = attachments?.["image"]
.presigned_url
? new Uint8Array(
(await fetch(attachments?.["image"].presigned_url).then(
(res) => res.arrayBuffer()
(await fetch(attachments?.["image"].presigned_url).then((res) =>
res.arrayBuffer()
)) as ArrayBuffer
)
: undefined;
Expand Down

0 comments on commit 7b2e73d

Please sign in to comment.