Skip to content
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

feat: python safenode module #2425

Merged
merged 15 commits into from
Nov 10, 2024
Merged

feat: python safenode module #2425

merged 15 commits into from
Nov 10, 2024

Conversation

dirvine
Copy link
Member

@dirvine dirvine commented Nov 10, 2024

Description

Please provide a brief description of the changes made in this pull request. Highlight the purpose of the changes and the problem they address.

Related Issue

Fixes #<issue_number> (if applicable).

Type of Change

Please mark the types of changes made in this pull request.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Checklist

Please ensure all of the following tasks have been completed:

  • I have read the contributing guidelines.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have updated the documentation accordingly.
  • I have followed the conventional commits guidelines for commit messages.
  • I have verified my commit messages with commitlint.

Adds Python bindings using PyO3 to allow direct programmatic control of
safenode instances. This enables Python applications to create and manage
Safe Network nodes without using the CLI or RPC interface.

Key changes:
- Add PyO3 integration and module structure
- Implement SafeNode Python class with core node functionality
- Add proper error handling and type conversions
- Include example code and documentation
- Add maturin build configuration
Adds comprehensive storage operations to the Python bindings, allowing direct
manipulation of node storage from Python applications.

Key changes:
- Add store_record() method for storing chunks with proper type handling
- Add get_record() method for retrieving stored data
- Add delete_record() method for removing stored data
- Add get_stored_records_size() for storage statistics
- Fix RecordKey and NetworkAddress type conversions
- Update example.py with storage operation demonstrations
- Update README with storage operation documentation

The storage operations now properly handle:
- Hex key conversions
- Record type validation
- Proper Kad record creation
- Network address and record key conversions
- Error handling and type safety

Example usage:
```python
node.store_record("1234abcd", b"Hello Network!", "chunk")
data = node.get_record("1234abcd")
size = node.get_stored_records_size()
```
Merge branch 'temp' into python
Also added flags to prevent publish of python workflows for now.

on:
push:
tags:
- 'XXX*'
- '*'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would trigger the workflow when any tag is pushed. I don't think we want this.

For now, I would just remove the whole trigger from the workflow. We can come back to this when we incorporate the bindings into the release process.


on:
push:
tags:
- 'v*'
- '*'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would trigger the workflow when any tag is pushed. I don't think we want this.

For now, I would just remove the whole trigger from the workflow. We can come back to this when we incorporate the bindings into the release process.

@jacderida jacderida merged commit bf1e173 into maidsafe:main Nov 10, 2024
27 of 28 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