Skip to content

Commit

Permalink
test: substantial
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-0acf4 committed Sep 20, 2024
1 parent c09e96d commit 81f34bd
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 188 deletions.
4 changes: 2 additions & 2 deletions src/typegate/src/runtimes/substantial/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { RunId, WorkerManager } from "./workflow_worker_manager.ts";

const logger = getLogger();

const POLL_INTERVAL_SECONDS = 2;
const POLL_INTERVAL_SECONDS = 1;
const LEASE_LIFESPAN = 3;

export interface WorkflowDescription {
Expand Down Expand Up @@ -99,7 +99,7 @@ export class Agent {

stop() {
this.workerManager.destroyAllWorkers();
if (this.pollIntervalHandle === undefined) {
if (this.pollIntervalHandle !== undefined) {
clearInterval(this.pollIntervalHandle);
}
}
Expand Down
10 changes: 6 additions & 4 deletions tests/runtimes/substantial/substantial.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typegraph import typegraph, t, Graph
from typegraph.policy import Policy
from typegraph.runtimes.substantial import SubstantialRuntime
Expand All @@ -8,7 +9,8 @@
def substantial(g: Graph):
pub = Policy.public()

backend = Backend.fs()
backend = Backend.memory() if os.environ["SUB_TEST_MEMORY"] == "1" else Backend.fs()

sub = SubstantialRuntime(backend)

save_and_sleep = sub.deno(
Expand All @@ -26,13 +28,13 @@ def substantial(g: Graph):
g.expose(
pub,
start=save_and_sleep.start(t.struct({"a": t.integer(), "b": t.integer()})),
resources=save_and_sleep.query_resources(),
workers=save_and_sleep.query_resources(),
results=save_and_sleep.query_results(
t.either([t.integer(), t.string()]).rename("ResultOrError")
),
start_email=sub_email.start(t.struct({"to": t.email()})),
send_confirmation=sub_email.send(t.boolean(), event_name="confirmation"),
ask_ongoing_emails=sub_email.query_resources(),
ask_email_results=sub_email.query_results(t.string()),
email_workers=sub_email.query_resources(),
email_results=sub_email.query_results(t.string()),
abort_email_confirmation=sub_email.stop(),
)
Loading

0 comments on commit 81f34bd

Please sign in to comment.