-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2/n] Add to_string method to AIConfigRuntime
Allow saving an AIConfigRuntime to a string by creating a `to_string` method that encapsulates the core business logic of the `save` method. This is needed for VSCode extension (top of stack), which sends the state of the AIConfigRuntime to the editor as a string for management (the IDE is responsible for managing the document, and for saving it to disk). Test Plan: Tested out getting started ipynb with: save JSON: ``` config = AIConfigRuntime.load('travel.aiconfig.json') config.save('travel2.aiconfig.json') ``` save YAML: ``` config.save('travel2.aiconfig.yaml', mode="yaml") ``` to JSON string: ``` config_str = config.to_string() print(config_str) ``` to YAML string: ``` config_yaml = config.to_string(mode="yaml") print(config_yaml) ``` For further sanity made sure that the generated strings could be loaded back as an AIConfig and `config.run` worked: ``` config = config.load_yaml(config_yaml) config.run(...) ```
- Loading branch information
Showing
2 changed files
with
78 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters