#Can someone please generally advise if
1 messages · Page 1 of 1 (latest)
@grand swan is there a #1030538312508776540 thread about this?
ok, found it here #1425783514820776027 message. Let's continue the discussion there please
after reading your question I'm still unsure about what you're trying to achieve here.
ok, I think I know what you're trying to do here. This is a good example that I'm not sure if/how self-calls might be able to help cc @nocturne sluice
@grand swan here's how you currently overcome this:
export class Lala {
/**
* Base func needed by other functions. It only needs a small number of files
* to run `pnpm install`, so we only copy those files to the container.
* This should be cached based on the contents of those files only.
*/
@func()
base(
@argument({ ignore: ["**", "!package.json", "!pnpm-lock.yaml"] })
source: Directory,
): Container {
return dag
.container()
.from("node:22.17")
.withExec(["corepack", "enable"])
.withWorkdir("/app")
.withDirectory("/app", source, {
include: ["package.json", "pnpm-lock.yaml"],
exclude: ["**/node_modules/**", "dist"],
})
.withExec(["pnpm", "install", "--frozen-lockfile"]);
}
/**
* A sample function that reads a specific file from the source directory
* and returns its contents as a string. It uses the base function to set up
* the container environment. Should be cached based on the contents of the
* relevant files only.
*/
@func()
async myFunc(source: Directory): Promise<string> {
const base = this.base(
dag.directory().withDirectory(".", source, {
include: ["package.json", "pnpm-lock.yaml"],
}),
).withDirectory("/app", source, {
include: ["relevant-to-my-func/**"],
});
return base.withExec(["cat", "relevant-to-my-func/file.md"]).stdout();
}
}
^ note the withDirectory call in the myFunc function
Unfortunately it doesn't work. When changing relevant-to-my-func/file.md it invalidates the base function cache and runs it instead of using the cached result.
strange.. this shouldn't happen. Let me setup a repro case and report back here
There's a discussion here: #1425419917477281803 message