Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for passthrough script executor config #74

Merged
merged 10 commits into from
Apr 3, 2024
7 changes: 7 additions & 0 deletions .changeset/warm-ravens-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@empiricalrun/types": minor
"@empiricalrun/core": minor
"@empiricalrun/cli": patch
---

feat: add support for passthrough config for script executor
2 changes: 1 addition & 1 deletion examples/basic/empiricalrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://assets.empirical.run/config/schema/v1.12.json",
"$schema": "https://assets.empirical.run/config/schema/v1.13.json",
"runs": [
{
"type": "model",
Expand Down
2 changes: 1 addition & 1 deletion examples/chatbot/empiricalrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://assets.empirical.run/config/schema/v1.12.json",
"$schema": "https://assets.empirical.run/config/schema/v1.13.json",
"runs": [
{
"name": "less context setting",
Expand Down
2 changes: 1 addition & 1 deletion examples/humaneval/empiricalrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://assets.empirical.run/config/schema/v1.12.json",
"$schema": "https://assets.empirical.run/config/schema/v1.13.json",
"runs": [
{
"type": "model",
Expand Down
2 changes: 1 addition & 1 deletion examples/rag/empiricalrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://assets.empirical.run/config/schema/v1.12.json",
"$schema": "https://assets.empirical.run/config/schema/v1.13.json",
"runs": [
{
"name": "rag script run",
Expand Down
2 changes: 1 addition & 1 deletion examples/rag/rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
nest_asyncio.apply()


def execute(inputs):
def execute(inputs, config):
# load documents
question = inputs["question"]
reader = SimpleDirectoryReader("./arxiv-papers/", num_files_limit=30)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/python/executor_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
sys.path.append(sys.argv[1])
user_module = importlib.import_module(sys.argv[2])

result = user_module.execute(json.loads(sys.argv[3]))
result = user_module.execute(json.loads(sys.argv[3]), json.loads(sys.argv[4]))
print("execution_output:", json.dumps(result))
7 changes: 6 additions & 1 deletion packages/core/src/run/executors/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ export const scriptExecutor: Executor = async (runConfig, sample) => {

let basePath = path.dirname(scriptPath);
let moduleName = path.basename(scriptPath).replace(".py", "");
let pythonArgs = [basePath, moduleName, JSON.stringify(sample.inputs)];
let pythonArgs = [
basePath,
moduleName,
JSON.stringify(sample.inputs),
JSON.stringify(runConfig.config || {}),
];

const runOutput = await new Promise<string[]>((resolve) => {
let output: string[] = [];
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ export interface ModelRunConfig extends RunConfigBase {
export interface JSScriptRunConfig extends RunConfigBase {
type: "js-script";
path: string;
config?: any;
}

export interface PyScriptRunConfig extends RunConfigBase {
type: "py-script";
path: string;
pythonPath?: string;
config?: any;
saikatmitra91 marked this conversation as resolved.
Show resolved Hide resolved
}

export type RunConfig = ModelRunConfig | PyScriptRunConfig | JSScriptRunConfig;
Expand Down
Loading