Skip to content

python example fail, python code format failures and much too long #198

@dasTholo

Description

@dasTholo

First off, I wanna say I'm super excited about this project! I get that you're just starting out. But I'd like to explain the hurdles for a non-Rust Python programmer. I can imagine that the SDKs for non-Rust languages might be less maintained than the main Rust project. That's totally clear to me! I just want to say this as constructive criticism. It's great that you already support installation via PyPi. But I was really confused when I realized it's just one file, "iroh_ffi.py". When I opened and read it, I was totally shocked.

Point 1:

  • Over 20k lines, that's not good! My IDE totally crashed (is that how you say it in English?) and couldn't handle it. 98% CPU usage.
    This means the applications need to be split up to improve performance and readability.
    Point 2:

  • The examples have errors

main.py Traceback

/home/tholo/Scripts/t_iroh/.venv/bin/python /home/tholo/Scripts/t_iroh/src/t_iroh/main.py
In example mode
(To run the sync demo, please provide a ticket to join a document)

Traceback (most recent call last):
File "/home/tholo/Scripts/t_iroh/src/t_iroh/main.py", line 71, in
asyncio.run(main())

File "/home/tholo/.rye/py/[email protected]/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)

File "/home/tholo/.rye/py/[email protected]/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)

File "/home/tholo/.rye/py/[email protected]/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()

File "/home/tholo/Scripts/t_iroh/src/t_iroh/main.py", line 28, in main
node_id = await node.node().node_id()

AttributeError: 'Node' object has no attribute 'node_id'

Process finished with exit code 1
Fix:

#node = await iroh.Iroh.memory()
#node_id = await node.node().node_id()
options = iroh.NodeOptions()
options.enable_docs = True
node = await iroh.Iroh.memory_with_options(options)

/home/tholo/Scripts/t_iroh/.venv/bin/python /home/tholo/Scripts/t_iroh/src/t_iroh/main.py
In example mode
(To run the sync demo, please provide a ticket to join a document)

Created doc: mp4chqhxybuuepskihamopytqakxxl5poboeezoktmaael7mq5ga

Created doc: egvzyk2lhxt4kwls4jcqqknjh3kgws3karl5r5i5pfibkjqjgirq

List all 2 docs:

NamespaceAndCapability(namespace=egvzyk2lhxt4kwls4jcqqknjh3kgws3karl5r5i5pfibkjqjgirq, capability=CapabilityKind.WRITE)
NamespaceAndCapability(namespace=mp4chqhxybuuepskihamopytqakxxl5poboeezoktmaael7mq5ga, capability=CapabilityKind.WRITE)

Process finished with exit code 0

Point 3:

  • Formatting errors, too many or too few blank lines, text too long, indentation errors
    Unused imports
    Integrate and use ruff (which is written in Rust for Python ;) ) or even pre-commit in the Github Actions, so these errors don't get committed.

I have started a PR #197

I look forward to exchanging ideas with you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions