Skip to content

Use YAML instead of JSON for worker config #299

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

anushkaShekar
Copy link

No description provided.

@anushkaShekar
Copy link
Author

anushkaShekar commented May 7, 2025

@tylerharter Modified the config.go, commands.go, and init.py files to use yaml instead of json. Just to clarify - is it necessary to change json to yaml in commands.go and init.py ? Thank you!

@tylerharter tylerharter changed the title modified config.go, commands.go, __init__.py Use YAML instead of JSON for worker config May 7, 2025
@anushkaShekar
Copy link
Author

@tylerharter Installed yaml for the CI tests

Copy link
Contributor

@Mandukhai-Alimaa Mandukhai-Alimaa left a comment

Choose a reason for hiding this comment

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

Hi Anushka, It seems that the the CI test is failing because the config.yaml is not created and populated correctly. I believe there is one more change need to be done in https://github.com/open-lambda/open-lambda/blob/main/src/worker/helpers.go#L147. It is still initializing config.json but trying to read config.yaml.

@@ -292,40 +292,31 @@ func checkConf(cfg *Config) error {
return nil
}

// SandboxConfJson marshals the Sandbox_config of the Config into a JSON string.
func SandboxConfJson() string {
Copy link
Contributor

@Mandukhai-Alimaa Mandukhai-Alimaa May 13, 2025

Choose a reason for hiding this comment

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

Just a quick check — are we confident that this function isn’t currently used or won’t be needed in the near future? Want to make sure we’re not removing something that might be useful down the line.

Copy link
Author

Choose a reason for hiding this comment

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

I will check this

Copy link
Author

Choose a reason for hiding this comment

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

Hi, @Mandukhai-Alimaa. I did a grep and it appears that this function is not being used anywhere else in the codebase. Should I delete it ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for checking! Yes, go ahead and delete it

@anushkaShekar
Copy link
Author

@Mandukhai-Alimaa Hi Mandy. I fixed the line in helpers.go to initialize config.yaml instead of config.json, but the CI tests are still failing (i'm getting this same error : FileNotFoundError: [Errno 2] No such file or directory: 'test-dir/config.yaml'). I tried searching for all instances of config.json and replacing it with config.yaml, but that still didn't work. not sure what i'm missing, so any help would be appreciated!

@Mandukhai-Alimaa
Copy link
Contributor

Mandukhai-Alimaa commented May 30, 2025

Hi @anushkaShekar, the debugging approach I’d recommend here is to trace the config file’s flow from start to finish. Identify where the file is being created, how it’s being written (and to which directory), and then track all the places where it’s being read.

Simply searching and replacing all instances of config.json with config.yaml might not catch everything, especially since IDEs can miss references depending on how they’re used. Following the file’s lineage explicitly will not only help you find the bug more reliably, but also give you a better understanding of the codebase, which will be helpful for future PRs.

It’s also useful to take a close look at the error trace. Here’s the traceback from the failure you encountered:

File "/home/runner/work/open-lambda/open-lambda/./scripts/test.py", line 369, in
main()
File "/home/runner/work/open-lambda/open-lambda/./scripts/test.py", line 355, in main
with TestConfContext(registry=os.path.abspath(args.registry), trace=trace_config):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/open-lambda/open-lambda/scripts/helper/init.py", line 107, in enter
self._conf = TestConf(**self._keywords)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/open-lambda/open-lambda/scripts/helper/init.py", line 72, in init
with open(os.path.join(_OL_DIR, "config.yaml"), "r", encoding='utf-8') as cfile:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'test-dir/config.yaml'
Error: Process completed with exit code 1.

This shows exactly where the failure occurs — test-dir/config.yaml is missing. I recommend looking at the files and line numbers mentioned here to better understand how the config file is being handled.

Let me know if you have any questions!

@anushkaShekar
Copy link
Author

Hi, @Mandukhai-Alimaa! I was able to get all the tests to pass, and just committed my changes. Please lmk if I need to make any additional changes at your convenience.

Copy link
Contributor

@Mandukhai-Alimaa Mandukhai-Alimaa left a comment

Choose a reason for hiding this comment

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

Nice work on this! Just a small thing — it looks like the default-ol and min-image directories were committed by mistake. These shouldn’t be part of the PR, so please remove them. Thanks!

Also, just double-checking — was the intent to update all three configs (worker, boss, and zygote tree) to YAML? I’m asking since @tylerharter mentioned:

"Good progress! Please make sure you're only changing the config with JSON => YAML. We're not trying to replace JSON everywhere, and it seems some code got swept up in that."

If the change to all three configs is indeed intended, it looks like the updated CI test still expects boss.json. You can go ahead and update the test to look for boss.yaml instead.

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.

2 participants