Skip to content

Conversation

@cmickeyb
Copy link
Contributor

Add send_file and recv_file to the guardian utility functions. These routines will use the keyvalue store for moving files to and from another service. While useful beyond the guardian, this is where they are most needed.

Eventually, it would be good to add comparable C++ routines that could be implemented within a contract.

Also improved the error handling and message generation for capability processing.

@cmickeyb cmickeyb requested a review from Copilot June 11, 2025 20:53
@cmickeyb cmickeyb self-assigned this Jun 11, 2025

This comment was marked as outdated.

@cmickeyb cmickeyb force-pushed the mic.jun11.guardian branch from 3dadaf3 to 839bafc Compare June 11, 2025 21:02
@cmickeyb cmickeyb requested a review from Copilot June 11, 2025 21:02
@cmickeyb cmickeyb force-pushed the mic.jun11.guardian branch from 839bafc to c0b4464 Compare June 11, 2025 21:05

This comment was marked as outdated.

Add send_file and recv_file to the guardian utility functions. These
routines will use the keyvalue store for moving files to and from
another service. While useful beyond the guardian, this is where they
are most needed.

Eventually, it would be good to add comparable C++ routines that
could be implemented within a contract.

Also improved the error handling and message generation for
capability processing.

Signed-off-by: Mic Bowman <mic.bowman@intel.com>
@cmickeyb cmickeyb force-pushed the mic.jun11.guardian branch from c0b4464 to 2eafb5d Compare June 11, 2025 22:13
@cmickeyb cmickeyb requested a review from Copilot June 11, 2025 22:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds helper routines for file transfer via the KeyValueStore and cleans up error handling in the guardian WSGI service.

  • Converts error logging and responses in process_capability.py to use F-strings and adds a guard around missing operation fields.
  • Introduces send_file and recv_file in common/utility.py for chunked file upload/download through the key-value store.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
common-contract/pdo/contracts/guardian/wsgi/process_capability.py Standardize exception logging with f-strings and add missing-field guard for dispatch
common-contract/pdo/contracts/guardian/common/utility.py Implement send_file/recv_file for chunked file operations in KVS
Comments suppressed due to low confidence (3)

common-contract/pdo/contracts/guardian/common/utility.py:36

  • The constant uses double underscores which is reserved for Python internals; consider renaming to CHUNK_SIZE to follow PEP 8 conventions.
__CHUNK_SIZE__ = 1024

common-contract/pdo/contracts/guardian/common/utility.py:39

  • New public functionality send_file lacks automated tests; consider adding unit tests that verify correct chunking, key generation, and KVS sync behavior.
def send_file(file_name, block_store = None, **kwargs):

common-contract/pdo/contracts/guardian/common/utility.py:59

  • The input_encoding='str' flag may misinterpret raw bytes; confirm the store expects a string or switch to a raw/binary mode to avoid data corruption.
with kv : _ = kv.set(f'{key}_{chunk_number}', chunk, input_encoding='str', output_encoding='raw')

@cmickeyb cmickeyb merged commit 1bf55fa into hyperledger-labs:main Jun 11, 2025
4 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.

1 participant