hippius 0.2.13__py3-none-any.whl → 0.2.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hippius-0.2.13.dist-info → hippius-0.2.14.dist-info}/METADATA +1 -1
- {hippius-0.2.13.dist-info → hippius-0.2.14.dist-info}/RECORD +8 -8
- hippius_sdk/__init__.py +1 -1
- hippius_sdk/cli_handlers.py +13 -18
- hippius_sdk/ipfs.py +76 -31
- hippius_sdk/ipfs_core.py +1 -3
- {hippius-0.2.13.dist-info → hippius-0.2.14.dist-info}/WHEEL +0 -0
- {hippius-0.2.13.dist-info → hippius-0.2.14.dist-info}/entry_points.txt +0 -0
@@ -1,17 +1,17 @@
|
|
1
|
-
hippius_sdk/__init__.py,sha256
|
1
|
+
hippius_sdk/__init__.py,sha256=MWFJq4fNljQXF2VRer9p01xKPsQLjrVgRNyuQc6xf8Q,1392
|
2
2
|
hippius_sdk/cli.py,sha256=pzwoa-X5cwdA_pM-fqUyXZKHgcZODrLe4qHZuCqQMtQ,18210
|
3
3
|
hippius_sdk/cli_assets.py,sha256=V3MX63QTiex6mCp0VDXQJ7cagm5v1s4xtsu8c1O4G_k,371
|
4
|
-
hippius_sdk/cli_handlers.py,sha256=
|
4
|
+
hippius_sdk/cli_handlers.py,sha256=TQNE9os87gRzRKLEO-SIwhFnBtEFMiaSESv-Bu7omfo,128909
|
5
5
|
hippius_sdk/cli_parser.py,sha256=Qh2wgkFBUTPldvGoTQuoNKQl5Vo0x6fPEsPBU5oymP4,20242
|
6
6
|
hippius_sdk/cli_rich.py,sha256=_jTBYMdHi2--fIVwoeNi-EtkdOb6Zy_O2TUiGvU3O7s,7324
|
7
7
|
hippius_sdk/client.py,sha256=TSfEQ-8Yq-4Dc0FZR9HNvDQ-CTzvCh7n8D1wdFwv-kc,19289
|
8
8
|
hippius_sdk/config.py,sha256=wVzhVIBtijatVG7MZ3HvAwdsz_-arkTvBf5NUiQHNTo,21841
|
9
9
|
hippius_sdk/errors.py,sha256=LScJJmawVAx7aRzqqQguYSkf9iazSjEQEBNlD_GXZ6Y,1589
|
10
|
-
hippius_sdk/ipfs.py,sha256=
|
11
|
-
hippius_sdk/ipfs_core.py,sha256=
|
10
|
+
hippius_sdk/ipfs.py,sha256=mxdovvcs5WjXD-b2A4tTfCF1G-kR6BSxskCCYlSmdMs,76937
|
11
|
+
hippius_sdk/ipfs_core.py,sha256=eOOgLoyP9mvwndnCjldnTc7z94ImYCXY3nm7JU3e_Mo,12676
|
12
12
|
hippius_sdk/substrate.py,sha256=lp-GF2qfZgD_XwZwc2UNNkp-AkGUpOiZQ5aJUiea8VA,49608
|
13
13
|
hippius_sdk/utils.py,sha256=rJ611yvwKSyiBpYU3w-SuyQxoghMGU-ePuslrPv5H5g,7388
|
14
|
-
hippius-0.2.
|
15
|
-
hippius-0.2.
|
16
|
-
hippius-0.2.
|
17
|
-
hippius-0.2.
|
14
|
+
hippius-0.2.14.dist-info/METADATA,sha256=obIQW4DLtFF2EtTviTw4u-A5sfA6rPOiPd0ZfurSabU,29993
|
15
|
+
hippius-0.2.14.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
16
|
+
hippius-0.2.14.dist-info/entry_points.txt,sha256=b1lo60zRXmv1ud-c5BC-cJcAfGE5FD4qM_nia6XeQtM,98
|
17
|
+
hippius-0.2.14.dist-info/RECORD,,
|
hippius_sdk/__init__.py
CHANGED
hippius_sdk/cli_handlers.py
CHANGED
@@ -970,26 +970,21 @@ async def handle_ec_files(
|
|
970
970
|
):
|
971
971
|
account_address = client.substrate_client._keypair.ss58_address
|
972
972
|
else:
|
973
|
-
#
|
974
|
-
|
975
|
-
if default_address:
|
976
|
-
account_address = default_address
|
977
|
-
else:
|
978
|
-
has_default = get_default_address() is not None
|
973
|
+
# Use the active account address instead of default address
|
974
|
+
from hippius_sdk.config import get_account_address, get_active_account
|
979
975
|
|
980
|
-
|
976
|
+
active_account = get_active_account()
|
977
|
+
if active_account:
|
978
|
+
account_address = get_account_address(active_account)
|
981
979
|
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
log(
|
991
|
-
" [bold green underline]hippius address set-default <your_account_address>[/bold green underline]"
|
992
|
-
)
|
980
|
+
if not account_address:
|
981
|
+
error("No account address provided and client has no keypair.")
|
982
|
+
info(
|
983
|
+
"Please provide an account address with '--account_address' or set an active account with:"
|
984
|
+
)
|
985
|
+
log(
|
986
|
+
" [bold green underline]hippius account switch <account_name>[/bold green underline]"
|
987
|
+
)
|
993
988
|
return 1
|
994
989
|
|
995
990
|
info(f"Getting erasure-coded files for account: [bold]{account_address}[/bold]")
|
hippius_sdk/ipfs.py
CHANGED
@@ -1751,6 +1751,7 @@ class IPFSClient:
|
|
1751
1751
|
cancel_from_blockchain: bool = True,
|
1752
1752
|
parallel_limit: int = 20,
|
1753
1753
|
seed_phrase: Optional[str] = None,
|
1754
|
+
metadata_timeout: int = 30, # Timeout in seconds for metadata fetch
|
1754
1755
|
) -> bool:
|
1755
1756
|
"""
|
1756
1757
|
Delete an erasure-coded file, including all its chunks in parallel.
|
@@ -1760,30 +1761,49 @@ class IPFSClient:
|
|
1760
1761
|
cancel_from_blockchain: Whether to cancel storage from blockchain
|
1761
1762
|
parallel_limit: Maximum number of concurrent deletion operations
|
1762
1763
|
seed_phrase: Optional seed phrase to use for blockchain interactions (uses config if None)
|
1764
|
+
metadata_timeout: Timeout in seconds for metadata fetch operation (default: 30)
|
1763
1765
|
|
1764
1766
|
Returns:
|
1765
1767
|
bool: True if the deletion was successful, False otherwise
|
1766
1768
|
"""
|
1769
|
+
print(f"Starting deletion process for metadata CID: {metadata_cid}")
|
1767
1770
|
|
1768
1771
|
# Try to download and process metadata file and chunks
|
1769
1772
|
ipfs_failure = False
|
1770
1773
|
metadata_error = False
|
1774
|
+
chunks = []
|
1771
1775
|
|
1772
1776
|
try:
|
1773
|
-
# First download the metadata to get chunk CIDs
|
1777
|
+
# First download the metadata to get chunk CIDs with timeout
|
1774
1778
|
try:
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
+
print("Attempting to fetch metadata file...")
|
1780
|
+
# Create a task for fetching metadata with timeout
|
1781
|
+
metadata_task = asyncio.create_task(self.cat(metadata_cid))
|
1782
|
+
try:
|
1783
|
+
metadata_result = await asyncio.wait_for(
|
1784
|
+
metadata_task, timeout=metadata_timeout
|
1785
|
+
)
|
1786
|
+
print(
|
1787
|
+
f"Successfully fetched metadata (size: {len(metadata_result['content'])} bytes)"
|
1788
|
+
)
|
1789
|
+
|
1790
|
+
# Parse the metadata JSON
|
1791
|
+
metadata_json = json.loads(
|
1792
|
+
metadata_result["content"].decode("utf-8")
|
1793
|
+
)
|
1794
|
+
chunks = metadata_json.get("chunks", [])
|
1795
|
+
print(f"Found {len(chunks)} chunks in metadata")
|
1796
|
+
except asyncio.TimeoutError:
|
1797
|
+
print(
|
1798
|
+
f"Timed out after {metadata_timeout}s waiting for metadata download"
|
1799
|
+
)
|
1800
|
+
# We'll continue with blockchain cancellation even without metadata
|
1801
|
+
except json.JSONDecodeError as e:
|
1779
1802
|
# If we can't parse the metadata JSON, record the error but continue
|
1780
|
-
|
1781
|
-
|
1782
|
-
chunks = []
|
1783
|
-
except Exception:
|
1803
|
+
print(f"Error parsing metadata JSON: {e}")
|
1804
|
+
except Exception as e:
|
1784
1805
|
# Any other metadata error
|
1785
|
-
|
1786
|
-
chunks = []
|
1806
|
+
print(f"Error retrieving or processing metadata: {e}")
|
1787
1807
|
|
1788
1808
|
# Extract all chunk CIDs
|
1789
1809
|
chunk_cids = []
|
@@ -1794,54 +1814,79 @@ class IPFSClient:
|
|
1794
1814
|
elif isinstance(chunk_cid, str):
|
1795
1815
|
chunk_cids.append(chunk_cid)
|
1796
1816
|
|
1817
|
+
print(f"Extracted {len(chunk_cids)} CIDs from chunks")
|
1818
|
+
|
1797
1819
|
# Create a semaphore to limit concurrent operations
|
1798
1820
|
semaphore = asyncio.Semaphore(parallel_limit)
|
1799
1821
|
|
1800
|
-
# Define the unpin task for each chunk with error handling
|
1822
|
+
# Define the unpin task for each chunk with error handling and timeout
|
1801
1823
|
async def unpin_chunk(cid):
|
1802
1824
|
async with semaphore:
|
1803
1825
|
try:
|
1804
|
-
|
1826
|
+
# Add a timeout for each unpin operation
|
1827
|
+
unpin_task = asyncio.create_task(self.client.unpin(cid))
|
1828
|
+
await asyncio.wait_for(
|
1829
|
+
unpin_task, timeout=10
|
1830
|
+
) # 10-second timeout per unpin
|
1805
1831
|
return {"success": True, "cid": cid}
|
1806
|
-
except
|
1832
|
+
except asyncio.TimeoutError:
|
1833
|
+
print(f"Unpin operation timed out for CID: {cid}")
|
1834
|
+
return {"success": False, "cid": cid, "error": "timeout"}
|
1835
|
+
except Exception as e:
|
1807
1836
|
# Record failure but continue with other chunks
|
1808
|
-
|
1837
|
+
print(f"Error unpinning CID {cid}: {str(e)}")
|
1838
|
+
return {"success": False, "cid": cid, "error": str(e)}
|
1809
1839
|
|
1810
1840
|
# Unpin all chunks in parallel
|
1811
1841
|
if chunk_cids:
|
1842
|
+
print(f"Starting parallel unpin of {len(chunk_cids)} chunks...")
|
1812
1843
|
unpin_tasks = [unpin_chunk(cid) for cid in chunk_cids]
|
1813
1844
|
results = await asyncio.gather(*unpin_tasks)
|
1814
1845
|
|
1815
1846
|
# Count failures
|
1816
1847
|
failures = [r for r in results if not r["success"]]
|
1817
1848
|
if failures:
|
1818
|
-
|
1819
|
-
|
1849
|
+
print(f"Failed to unpin {len(failures)} chunks")
|
1850
|
+
else:
|
1851
|
+
print("Successfully unpinned all chunks")
|
1852
|
+
except Exception as e:
|
1820
1853
|
# If we can't process chunks at all, record the failure
|
1821
|
-
|
1854
|
+
print(f"Exception during chunks processing: {e}")
|
1822
1855
|
|
1823
1856
|
# Unpin the metadata file itself, regardless of whether we could process chunks
|
1824
1857
|
try:
|
1825
|
-
|
1826
|
-
|
1858
|
+
print(f"Unpinning metadata file: {metadata_cid}")
|
1859
|
+
unpin_task = asyncio.create_task(self.client.unpin(metadata_cid))
|
1860
|
+
await asyncio.wait_for(unpin_task, timeout=10) # 10-second timeout
|
1861
|
+
print("Successfully unpinned metadata file")
|
1862
|
+
except Exception as e:
|
1827
1863
|
# Record the failure but continue with blockchain cancellation
|
1828
|
-
|
1864
|
+
print(f"Error unpinning metadata file: {e}")
|
1829
1865
|
|
1830
1866
|
# Handle blockchain cancellation if requested
|
1831
1867
|
if cancel_from_blockchain:
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1868
|
+
try:
|
1869
|
+
# Create a substrate client
|
1870
|
+
print("Creating substrate client for blockchain cancellation...")
|
1871
|
+
substrate_client = SubstrateClient()
|
1872
|
+
|
1873
|
+
# This will raise appropriate exceptions if it fails:
|
1874
|
+
# - HippiusAlreadyDeletedError if already deleted
|
1875
|
+
# - HippiusFailedSubstrateDelete if transaction fails
|
1876
|
+
# - Other exceptions for other failures
|
1877
|
+
print(f"Cancelling storage request for CID: {metadata_cid}")
|
1878
|
+
await substrate_client.cancel_storage_request(
|
1879
|
+
metadata_cid, seed_phrase=seed_phrase
|
1880
|
+
)
|
1881
|
+
print("Successfully cancelled storage request on blockchain")
|
1882
|
+
except Exception as e:
|
1883
|
+
print(f"Error during blockchain cancellation: {e}")
|
1884
|
+
# Re-raise the exception to be handled by the caller
|
1885
|
+
raise
|
1842
1886
|
|
1843
1887
|
# If we get here, either:
|
1844
1888
|
# 1. Blockchain cancellation succeeded (if requested)
|
1845
1889
|
# 2. We weren't doing blockchain cancellation
|
1846
1890
|
# In either case, we report success
|
1891
|
+
print("Delete EC file operation completed successfully")
|
1847
1892
|
return True
|
hippius_sdk/ipfs_core.py
CHANGED
@@ -141,9 +141,7 @@ class AsyncIPFSClient:
|
|
141
141
|
Returns:
|
142
142
|
Response from the IPFS node
|
143
143
|
"""
|
144
|
-
|
145
|
-
pin_ls_response = await self.client.post(pin_ls_url)
|
146
|
-
pin_ls_response.raise_for_status()
|
144
|
+
|
147
145
|
response = await self.client.post(f"{self.api_url}/api/v0/pin/rm?arg={cid}")
|
148
146
|
|
149
147
|
response.raise_for_status()
|
File without changes
|
File without changes
|