Skip to content

Refactor: Migrate message commands to aleph-sdk-python #150 #163

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

Merged
merged 20 commits into from
Jul 10, 2023

Conversation

1yam
Copy link
Member

@1yam 1yam commented Jul 7, 2023

From : #150

Refactor:

  • Remove deprecated example of usage using mqtt.py.
  • Fix mypy errors:
    • Replace typer.echo with typer.secho in account module.
    • Resolve type conversion errors in message module.
  • Fix unit tests and integration tests.

@odesenfans odesenfans changed the base branch from master to hoh-refactor-sdk-146 July 7, 2023 11:18
channels_s: Optional[list[str]] = None
chains_s: Optional[list[str]] = None

content_types_s = content_types.split(",") if content_types else None
Copy link
Contributor

Choose a reason for hiding this comment

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

Why _s? These variables are not strings. Maybe use something like parsed_content_keys ?

Copy link
Member Author

Choose a reason for hiding this comment

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

_s = _splited in my head

@@ -25,6 +25,17 @@
app = typer.Typer()


def str_to_datetime(date: Optional[str]) -> Optional[datetime]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a docstring to explain that this function can take either a timestamp or an ISO format datetime as parameter.

timeout=5,
hashes=[post_message.item_hash],
api_server=receiver_node,
data = {'content': 'test'}
Copy link
Contributor

Choose a reason for hiding this comment

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

This dictionary appears to be unused.

Copy link
Member Author

Choose a reason for hiding this comment

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

async with AuthenticatedAlephClient(
account=fixture_account, api_server=sdk_settings.API_HOST
) as client:
result, status = await client.create_post(
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename result to message.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, now that the SDK returns a status, you can assert that the operation worked with assert status == ....

response = await try_until(
get_message,
lambda r: r is not None and r.content is not None,
timeout=50,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 50? Revert to 5, that's too long. Note that you can also specify sync=True in client.create_post to make sure that the message was processed on the API node.

@odesenfans odesenfans changed the base branch from hoh-refactor-sdk-146 to master July 10, 2023 08:18
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