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

Feature: Cli download commands aleph & ipfs #165

Closed
wants to merge 11 commits into from

Conversation

1yam
Copy link
Collaborator

@1yam 1yam commented Jul 11, 2023

Solutions:

  • Create a new command that allows users to download a file from a hash.

if not use_ipfs:
file_content = client.download_file(item_hash)
else:
file_content = client.download_file_ipfs(item_hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can now use download_file_to_buffer to reduce memory usage.

write content of file download to byte into a path
"""
file_path = Path(path)
file_path.write_bytes(content)
Copy link
Contributor

Choose a reason for hiding this comment

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

This function will be useless once you use download_file_to_buffer.

@hoh hoh assigned 1yam Sep 26, 2023
Copy link
Member

@MHHukiewitz MHHukiewitz left a comment

Choose a reason for hiding this comment

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

LGTM, only minor formating issues, use isort, flake8 & black

@@ -7,6 +7,7 @@
from pygments.lexers import JsonLexer
from typer import echo
from datetime import datetime
from pathlib import Path
Copy link
Member

Choose a reason for hiding this comment

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

unneeded import

@@ -122,3 +123,4 @@ def str_to_datetime(date: Optional[str]) -> Optional[datetime]:
except ValueError:
pass
return datetime.fromisoformat(date)

Copy link
Member

Choose a reason for hiding this comment

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

you can revert this file

@@ -15,4 +15,4 @@ def test_get_message_type_value():
assert get_message_type_value(AggregateMessage) == MessageType.aggregate
assert get_message_type_value(StoreMessage) == MessageType.store
assert get_message_type_value(ProgramMessage) == MessageType.program
assert get_message_type_value(ForgetMessage) == MessageType.forget
assert get_message_type_value(ForgetMessage) == MessageType.forget
Copy link
Member

Choose a reason for hiding this comment

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

seems also unneeded? Maybe it's due to auto formatting

if path is None:
path = item_hash

with AlephClient(api_server=sdk_settings.API_HOST) as client:
Copy link
Member

Choose a reason for hiding this comment

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

This is the wrong import, try using async with AlephHttpClient

@MHHukiewitz
Copy link
Member

Closing this PR and will be superseded by a fresh branch. GH seems to not handle some of the rebases/force-pushes well that happened here

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.

4 participants