Add fetch command to retrieve memory keys from Redis#11
Merged
Gerico1007 merged 10 commits intomainfrom Mar 26, 2025
Merged
Conversation
Related to #10 Add `fetch_key_val` function to fetch value from Redis and handle errors gracefully. * Implement `fetch_key_val` function in `coaiapy/coaiamodule.py` to fetch value from Redis and handle errors. * Handle `--output` flag in `fetch_key_val` to save value to file if specified. * Exit with code 1 and print error message if key is not found. * Exit with code 2 and print error message if Redis is unreachable. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/jgwill/coaiapy/issues/10?shareId=XXXX-XXXX-XXXX-XXXX).
* **Import fetch_key_val**: Import `fetch_key_val` function from `coaiamodule`. * **Add subparser**: Add subparser for `fetch` command to retrieve memory keys from Redis. * **Add --output flag**: Add `--output` flag to `fetch` command to save value to file if specified. * **Update argparse setup**: Update argparse setup to call `fetch_key_val` function for `fetch` command.
* **Test for stdout output**: Verify that `fetch_key_val` prints the value to stdout if the key is found. * **Test for file output**: Verify that `fetch_key_val` saves the value to a file if the `--output` flag is specified. * **Test for key not found**: Verify that `fetch_key_val` exits with code 1 and prints an error message if the key is not found. * **Test for Redis unreachable**: Verify that `fetch_key_val` exits with code 2 and prints an error message if Redis is unreachable.
…eys from Redis * Add section "Fetch Value from Redis" with examples for fetching value by key and saving to file
…t coverage #10 -By Copilot
…ors gracefully * Add `fetch_key_val` function to handle Redis connection, key retrieval, and error handling * Update `fetch_key_val` to handle `--output` flag and save value to file if specified * Update `fetch_key_val` to exit with code 1 and print error message if key is not found * Update `fetch_key_val` to exit with code 2 and print error message if Redis is unreachable
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #10
Add
fetch_key_valfunction to fetch value from Redis and handle errors gracefully.fetch_key_valfunction incoaiapy/coaiamodule.pyto fetch value from Redis and handle errors.--outputflag infetch_key_valto save value to file if specified.For more details, open the Copilot Workspace session.