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

MessageCache and LightNode #59

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*.pot
__pycache__/*
.cache/*
cache/**/*
.*.swp
*/.ipynb_checkpoints/*

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ install_requires =
# Required to fix a dependency issue with parsimonious and Python3.11
eth_abi==4.0.0b2; python_version>="3.11"
python-magic
peewee
# The usage of test_requires is discouraged, see `Dependency Management` docs
# tests_require = pytest; pytest-cov
# Require a specific Python version, e.g. Python 2.7 or >= 3.4
Expand Down
4 changes: 2 additions & 2 deletions src/aleph/sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pkg_resources import DistributionNotFound, get_distribution

from aleph.sdk.client import AlephHttpClient, AuthenticatedAlephHttpClient
from aleph.sdk.client import AlephHttpClient, AuthenticatedAlephHttpClient, LightNode
Copy link
Collaborator

Choose a reason for hiding this comment

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

Current discussion with @hoh : we might want to use another name for this class


try:
# Change here if project is renamed and does not equal the package name
Expand All @@ -11,4 +11,4 @@
finally:
del get_distribution, DistributionNotFound

__all__ = ["AlephHttpClient", "AuthenticatedAlephHttpClient"]
__all__ = ["AlephHttpClient", "AuthenticatedAlephHttpClient", "LightNode"]
4 changes: 4 additions & 0 deletions src/aleph/sdk/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from .abstract import AlephClient, AuthenticatedAlephClient
from .authenticated_http import AuthenticatedAlephHttpClient
from .http import AlephHttpClient
from .light_node import LightNode
from .message_cache import MessageCache

__all__ = [
"AlephClient",
"AuthenticatedAlephClient",
"AlephHttpClient",
"AuthenticatedAlephHttpClient",
"MessageCache",
"LightNode",
]
8 changes: 8 additions & 0 deletions src/aleph/sdk/client/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import aiohttp
from aleph_message import parse_message
from aleph_message.models import AlephMessage, ItemHash, ItemType
from aleph_message.status import MessageStatus
from pydantic import ValidationError

from ..conf import settings
Expand Down Expand Up @@ -178,6 +179,8 @@ async def download_file_to_buffer(
)
else:
raise FileTooLarge(f"The file from {file_hash} is too large")
else:
response.raise_for_status()

async def download_file_ipfs_to_buffer(
self,
Expand Down Expand Up @@ -343,6 +346,11 @@ async def get_message_error(
"details": message_raw["details"],
}

async def get_message_status(self, item_hash: str) -> MessageStatus:
async with self.http_session.get(f"/api/v0/messages/{item_hash}") as resp:
resp.raise_for_status()
return MessageStatus((await resp.json())["status"])

async def watch_messages(
self,
message_filter: Optional[MessageFilter] = None,
Expand Down
Loading
Loading