Skip to content

Initial ReqBench init function #402

Open
parallax9999 wants to merge 12 commits intoopen-lambda:mainfrom
parallax9999:main
Open

Initial ReqBench init function #402
parallax9999 wants to merge 12 commits intoopen-lambda:mainfrom
parallax9999:main

Conversation

@parallax9999
Copy link

Added the function run_reqbench_init, which:

  • pulls the requirements.csv file from the open-lambda/ReqBench repo
  • extracts the requirements.txt files located in the csv file
  • creates lambdas for each txt file

Copy link
Member

@tylerharter tylerharter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some feedback on "init". Lets figure that out, and then later I will give feedback on the actual execution.

}
func run_reqbench_init(ctx *cli.Context) error {
olPath, err := common.GetOlPath(ctx)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix up spacing, use "go fmt"

csvFilename := "requirements.csv"
csvFile, err := os.Create(csvFilename)
if err != nil {
return err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general, try to wrap errors to give more context, something like this:

fmt.Errorf("reqbench init failed to create file: %w", err)

return err
}
// pull requirements.csv
csvUrl := "https://raw.githubusercontent.com/open-lambda/ReqBench/refs/heads/main/files/requirements.csv"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add TODO comment to make this configurable.

return err
}

csvFile.Seek(0, 0) // for each line
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use the same open file. Move download stuff to a helper function somewhere. Then just open it normally, without a seek.

log.Fatal(err)
}
for i := 0; ; i++ {
repo, err := reader.Read()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't "repo" actually a whole row? confusing name for it

}
// get requirements.txt
// http.Get https://raw.githubusercontent.com/repo[1]/repo[2]/repo[3]
txtUrl := "https://raw.githubusercontent.com/" + repo[1] + "/" + repo[2] + "/" + repo[3]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't hardcode col positions. Actually use the header (skipped earlier) to figure out col indexes.

// get requirements.txt
// http.Get https://raw.githubusercontent.com/repo[1]/repo[2]/repo[3]
txtUrl := "https://raw.githubusercontent.com/" + repo[1] + "/" + repo[2] + "/" + repo[3]
txtResponse, err := http.Get(txtUrl)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to download something else? I think we have the "compiled" field with the pip compiled requirements.txt in the dataset already, right?

txtUrl := "https://raw.githubusercontent.com/" + repo[1] + "/" + repo[2] + "/" + repo[3]
txtResponse, err := http.Get(txtUrl)
if err != nil {
fmt.Printf("Failed to download requirements for lambda %d: %v\n", i, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If something like this fails, better to fail the benchmark than having different people getting different results because they missed a warning.

registryPath := strings.TrimPrefix(common.Conf.Registry, "file://")
lambdaPath := filepath.Join(registryPath, lambdaName)

if err := os.MkdirAll(lambdaPath, 0755); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? Do other benchmarks in this file still work?

I figured we would need to use the new admin install:

https://github.com/open-lambda/open-lambda/blob/main/docs/worker/getting-started.md#using-provided-examples

Maybe not?

continue
}

functionCode := `def f(event):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it going to import anything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants