Skip to content

Commit 01d5b1a

Browse files
destifoNatoandro
andauthored
feat(SDK): add globs and dir support for artifact deps. (#698)
- [x] Include glob and dir support for `PythonRuntime` deps. - [x] Include glob and dir support for `DenoRuntime` deps. - [x] add tests The change includes support for declaring artifact dependencies through `globs` and `dirs` <!-- 2. Explain below WHY the change cannot be made simpler --> <!-- 3. Explain below WHY the was made or link an issue number --> [MET-441](https://linear.app/metatypedev/issue/MET-441/sdk-support-globs-and-directories-in-artifact-dependencies) <!-- 4. Explain HOW users should update their code or remove that section --> #### Migration notes In the `deps` parameter for `python.import(...)` and `deno.import(...)`, globs and dirs can be passed in addition to files. - [x] The change come with new or modified tests - [ ] Hard-to-understand functions have explanatory comments - [ ] End-user documentation is updated to reflect the change <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced functionality for defining and deploying Typegraphs for Deno and Python runtimes. - Added support for defining a Deno runtime dependency graph with policies for test scenarios. - **Bug Fixes** - Corrected the structure of the `Deno.serve` call in the `serve` function. - **Refactor** - Enhanced method chaining for better readability in the `MetaTest` class. - **Tests** - Updated test coverage reporting to include new Deno runtime test files. - Commented out and removed outdated test cases in Deno runtime tests. - **Chores** - Updated platform specification in configuration files. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Natoandro <[email protected]>
1 parent 8bf253b commit 01d5b1a

23 files changed

+938
-26
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typegate/deno.lock

Lines changed: 194 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typegate/src/sync/typegraph.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ export class TypegraphStore {
4141
);
4242
const data = JSON.stringify([typegraph, encryptedSecrets]);
4343
const hash = encodeHex(
44-
await crypto.subtle.digest(
45-
"SHA-256",
46-
new TextEncoder().encode(data),
47-
),
44+
await crypto.subtle.digest("SHA-256", new TextEncoder().encode(data)),
4845
);
4946

5047
const id = {
@@ -53,19 +50,15 @@ export class TypegraphStore {
5350
uploadedAt: new Date(),
5451
};
5552

56-
await this.#uploadData(
57-
this.bucket,
58-
TypegraphStore.#getKey(this.bucket, id),
59-
data,
60-
);
53+
await this.#uploadData(this.bucket, TypegraphStore.#getKey(id), data);
6154

6255
return id;
6356
}
6457

6558
public async download(
6659
id: TypegraphId,
6760
): Promise<[TypeGraphDS, SecretManager]> {
68-
const key = TypegraphStore.#getKey(this.bucket, id);
61+
const key = TypegraphStore.#getKey(id);
6962
const data = await this.#downloadData(this.bucket, key);
7063
const [typegraph, encryptedSecrets] = JSON.parse(data) as [
7164
TypeGraphDS,
@@ -77,10 +70,10 @@ export class TypegraphStore {
7770
return [typegraph, secretManager];
7871
}
7972

80-
static #getKey(bucket: string, typegraphId: TypegraphId) {
73+
static #getKey(typegraphId: TypegraphId) {
8174
const { name, hash, uploadedAt } = typegraphId;
8275
const uploadDate = uploadedAt.toISOString();
83-
return `${bucket}/typegraphs/${name}/typegraph.json.${uploadDate}.${hash}`;
76+
return `typegraphs/${name}/typegraph.json.${uploadDate}.${hash}`;
8477
}
8578

8679
async #uploadData(bucket: string, key: string, data: string) {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from typegraph.graph.typegraph import Graph
2+
from typegraph.policy import Policy
3+
from typegraph.runtimes.deno import DenoRuntime
4+
5+
from typegraph import t, typegraph
6+
7+
8+
@typegraph()
9+
def deno_dir(g: Graph):
10+
deno = DenoRuntime()
11+
public = Policy.public()
12+
13+
g.expose(
14+
public,
15+
test_dir=deno.import_(
16+
t.struct({"a": t.float(), "b": t.float()}),
17+
t.float(),
18+
module="ts/dep/main.ts",
19+
deps=["ts/dep"],
20+
name="doAddition",
21+
),
22+
)

0 commit comments

Comments
 (0)