Skip to content

Commit

Permalink
Merge pull request #2430 from dirvine/tmp_pub
Browse files Browse the repository at this point in the history
fix: python publish workflow
  • Loading branch information
jacderida authored Nov 12, 2024
2 parents 4402dc1 + 7efcdd5 commit a6360c8
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 65 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/python-publish-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and Publish Python Client Package
on:
push:
tags:
- 'XXX*'
- 'xxx'

permissions:
id-token: write
Expand Down Expand Up @@ -32,14 +32,14 @@ jobs:
run: |
mkdir -p autonomi/python/autonomi_client
cat > autonomi/python/autonomi_client/__init__.py << EOL
from ._autonomi import *
from .autonomi_client import *
__version__ = "${{ github.ref_name }}"
EOL
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
args: --release --out dist --find-interpreter --compatibility manylinux2014
sccache: 'true'
working-directory: ./autonomi
- name: Upload wheels
Expand Down Expand Up @@ -79,12 +79,12 @@ jobs:
shell: cmd
run: |
if not exist "autonomi\python\autonomi_client" mkdir autonomi\python\autonomi_client
echo from ._autonomi import * > autonomi\python\autonomi_client\__init__.py
echo from .autonomi_client import * > autonomi\python\autonomi_client\__init__.py
echo __version__ = "${{ github.ref_name }}" >> autonomi\python\autonomi_client\__init__.py
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
args: --release --out dist
args: --release --out dist --find-interpreter --compatibility manylinux2014
sccache: 'true'
working-directory: ./autonomi
- name: Upload wheels
Expand Down Expand Up @@ -129,15 +129,15 @@ jobs:
run: |
mkdir -p autonomi/python/autonomi_client
cat > autonomi/python/autonomi_client/__init__.py << EOL
from ._autonomi import *
from .autonomi_client import *
__version__ = "${{ github.ref_name }}"
EOL
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist
manylinux: "2014"
args: --release --out dist --find-interpreter
sccache: 'true'
working-directory: ./autonomi
before-script-linux: |
Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
run: |
mkdir -p autonomi/python/autonomi_client
cat > autonomi/python/autonomi_client/__init__.py << EOL
from ._autonomi import *
from .autonomi_client import *
__version__ = "${{ github.ref_name }}"
EOL
- name: Build sdist
Expand Down Expand Up @@ -221,6 +221,15 @@ jobs:
echo "Final dist directory contents:"
ls -la dist/
- name: Check if version exists
run: |
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}" # Remove 'v' prefix if present
if pip index versions autonomi-client | grep -q "${VERSION}"; then
echo "Version ${VERSION} already exists on PyPI"
exit 1
fi
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and Publish Python Node Package
on:
push:
tags:
- 'XXX*'
- 'xxx'

permissions:
id-token: write
Expand Down
3 changes: 3 additions & 0 deletions autonomi/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ classifiers = [
"Programming Language :: Rust",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
]
dependencies = [
"pip>=24.3.1",
]
22 changes: 0 additions & 22 deletions sn_node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,6 @@ Directory Management:
- `get_logs_dir() -> str`: Get logs directory path
- `get_data_dir() -> str`: Get data storage directory path

#### Storage Example

```python
# Store some data
key = "1234567890abcdef" # Hex string key
data = b"Hello, Safe Network!"
node.store_record(key, data, "chunk")

# Retrieve the data
stored_data = node.get_record(key)
if stored_data:
print(f"Retrieved: {stored_data.decode()}")

# Get storage info
size = node.get_stored_records_size()
print(f"Total storage used: {size} bytes")

# Delete data
if node.delete_record(key):
print("Data deleted successfully")
```

#### Directory Management Example

```python
Expand Down
2 changes: 1 addition & 1 deletion sn_node/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "safenode"
version = "0.112.3"
dynamic = ["version"]
description = "SAFE Network Node"
requires-python = ">=3.8"
dependencies = [
Expand Down
34 changes: 2 additions & 32 deletions sn_node/python/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,7 @@ def demonstrate_basic_node_operations():

return node, peer_id

def demonstrate_storage_operations(node):
print_section("Storage Operations")

# Store data
key = "1234567890abcdef" # Example hex key
data = b"Hello, Safe Network!"

try:
# Store a chunk
node.store_record(key, data, "chunk")
print(f"Successfully stored chunk with key: {key}")

# Retrieve the data
stored_data = node.get_record(key)
if stored_data:
print(f"Retrieved data: {stored_data.decode()}")

# Get storage stats
size = node.get_stored_records_size()
print(f"Total storage used: {size} bytes")

# List all stored records
addresses = node.get_all_record_addresses()
print(f"Stored record addresses: {addresses}")

# Delete the record
if node.delete_record(key):
print(f"Successfully deleted record: {key}")
except Exception as e:
print(f"Storage operation failed: {e}")


def demonstrate_network_operations(node):
print_section("Network Operations")
Expand Down Expand Up @@ -128,8 +99,7 @@ def main():
# Basic setup and node operations
node, peer_id = demonstrate_basic_node_operations()

# Storage operations
demonstrate_storage_operations(node)


# Network operations
demonstrate_network_operations(node)
Expand Down

0 comments on commit a6360c8

Please sign in to comment.