Skip to content

Add fetch command to retrieve memory keys from Redis#11

Merged
Gerico1007 merged 10 commits intomainfrom
coaia-10-add-fetch-command
Mar 26, 2025
Merged

Add fetch command to retrieve memory keys from Redis#11
Gerico1007 merged 10 commits intomainfrom
coaia-10-add-fetch-command

Conversation

@jgwill
Copy link
Copy Markdown
Owner

@jgwill jgwill commented Mar 22, 2025

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.

jgwill added 10 commits March 22, 2025 15:37
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
…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
@Gerico1007 Gerico1007 merged commit 4b52010 into main Mar 26, 2025
0 of 3 checks passed
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