Skip to content

Commit

Permalink
Update codegen to use the latest OpenAPI spec (#81)
Browse files Browse the repository at this point in the history
* Update codegen to use the latest OpenAPI spec

* Update RunPython example
  • Loading branch information
liamgriffiths authored May 31, 2024
1 parent e0b2f75 commit 2912147
Show file tree
Hide file tree
Showing 10 changed files with 916 additions and 1,226 deletions.
38 changes: 7 additions & 31 deletions examples/kitchen-sink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ import {
StableDiffusionXLIPAdapter,
StableDiffusionXLControlNet,
FillMask,
BigLaMa,
UpscaleImage,
RealESRGAN,
RemoveBackground,
DISISNet,
SegmentUnderPoint,
SegmentAnything,
TranscribeMedia,
Expand All @@ -45,7 +42,7 @@ import {
Mixtral8x7BInstruct,
Llama3Instruct8B,
Llama3Instruct70B,
RunCode,
RunPython,
} from "substrate";

const urls = {
Expand Down Expand Up @@ -473,29 +470,6 @@ const examples = [
}),
envs: ALL_ENVS,
},
{
// FIXME: it looks like this should work for v1, but doesn't yet
node: new DISISNet({
image_uri: "https://media.substrate.run/docs-seurat.jpg",
store: "hosted",
}),
envs: [STAGING_V0, PRODUCTION_V1],
},
{
node: new BigLaMa({
image_uri: "https://media.substrate.run/docs-seurat.jpg",
mask_image_uri: "https://media.substrate.run/spiral-logo.jpeg",
// store: "hosted", // FIXME: not working yet
}),
envs: [STAGING_V1, PRODUCTION_V1],
},
{
node: new RealESRGAN({
image_uri: "https://media.substrate.run/docs-seurat.jpg",
// store: "hosted", // FIXME: not working yet
}),
envs: [STAGING_V1, PRODUCTION_V1],
},
{
node: new SegmentAnything({
image_uri: "https://media.substrate.run/docs-vg-bedroom.jpg",
Expand Down Expand Up @@ -535,10 +509,12 @@ const examples = [
envs: [STAGING_V1, PRODUCTION_V1],
},
{
node: new RunCode({
language: "python",
code: `import sys; print(f"hello {sys.argv[1]}")`,
args: ["substrate"],
node: new RunPython({
code: "import numpy as np; print(SB_IN['foo']); SB_OUT['result']=np.sum([1,2]).item()",
input: {
foo: "bar",
},
pip_install: ["numpy"],
}),
envs: [STAGING_V1, PRODUCTION_V1],
},
Expand Down
22 changes: 22 additions & 0 deletions examples/run-python.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env -S npx ts-node --transpileOnly

import { Substrate, RunPython } from "substrate";

async function main() {
const SUBSTRATE_API_KEY = process.env["SUBSTRATE_API_KEY"];

const substrate = new Substrate({ apiKey: SUBSTRATE_API_KEY });

const node = new RunPython({
code: "import numpy as np; print(SB_IN['foo']); SB_OUT['result']=np.sum([1,2]).item()",
input: {
foo: "bar",
},
pip_install: ["numpy"],
});

const res = await substrate.run(node);

console.log(res.get(node));
}
main();
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "substrate",
"version": "120240418.0.13",
"version": "120240530.0.13",
"description": "The official SDK for the Substrate API",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/GEN_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20240418.20240430
20240530.20240531
Loading

0 comments on commit 2912147

Please sign in to comment.