Giter Site home page Giter Site logo

pinnaculum / aioipfs Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 6.0 177 KB

Asynchronous IPFS client library (python3) Mirror of: https://gitlab.com/cipres/aioipfs

License: GNU Lesser General Public License v3.0

Python 100.00%
ipfs ipfs-api python3 aio-lib asyncio go-ipfs aio-library kubo aiohttp-client

aioipfs's Introduction

I don't use this platform anymore (only keeping a few mirror repos around). All my opensource work is done on GitLab as @cipres.

aioipfs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aioipfs's Issues

Problem with IPFS file download

I try to get the NFT image (e.g. https://ipfs.io/ipfs/QmVFPvu8aeJHXyNVxpfftVHaKjRsbtH6dXWscJ2TukM3xi ) from IPFS as follows:

  1. Run IPFS daemon
  2. Run small script:
async def main():
	client = aioipfs.AsyncIPFS()
	print(client)
	await client.core.get('QmVFPvu8aeJHXyNVxpfftVHaKjRsbtH6dXWscJ2TukM3xi', dstdir='/tmp')
	await client.close()

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

I receive the following error:
Could not remove TAR file: [WinError 32] The process cannot access the file because it is being used by another process: 'file path'

Py-test problems

Greetings,
I am not sure when u did the last pytest run -- the tests don't work:

  1. At least, you need to include for event_loop for following code - or nothing works.
    @pytest.fixture
    def event_loop():
    loop = asyncio.new_event_loop()
    yield loop
    loop.close()
  2. When a test failed it block the corresponding localhost ports - I get the following error:
  • Error: serveHTTPGateway: manet.Listen(/ip4/127.0.0.1/tcp/9080) failed: listen tcp4 127.0.0.1:9080: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.
    So (failed tests) occupy ports -- which means that, I assume sockets were used in a way that made them persistently bind itself to given ports. This may reveal a much bigger problem -- What happen to the ports in a production or app environment when the used "cmd" can't be closed - or the app must be restarted to have these locked ports being removed ...? I am not aware that there is an external tool that I can use to close these IP ports.
    Or:
  1. how about using some auto-clean function like:
    @pytest.fixture(autouse=True)
    async def cleanup_after_test():
    yield
    • Perform cleanup actions, e.g., release ports
    • Close any remaining connections
    • Ensure that all resources are properly released after each test
      Just a thought
      Best
      Ike

Error processing car file: car stream not convertible to bytes

Summary

I've followed the example to process a locally downloaded car file (see the cid here) but cannot stream the file contents. It runs into an error: car stream for ... not convertable to bytes.

Details

Here's the example implementation from the docs:

from pathlib import Path
from aioipfs import util

data = await util.car_bytes(
    util.car_open(Path('docs.car')),
    'bafybeiawyahkjt4kzrzc3bjylqupniukbpnbvys7pt536c64gxg7onq36m'
)

Here's my setup. After downloading the car file locally (it's V2 iirc), I try to drop it into the snippet above. I can successfully use car_open (it shows the pointer to <ipfs_car_decoder.async_stream.FileByteStream object at 0x104c97c90>), but trying to run car_bytes is where the error is thrown.

from pathlib import Path
from aioipfs import util
from asyncio import run

async def process_car_file():
    try:
        data = await util.car_bytes(
            util.car_open(Path('bafybeiajgoqpcayvds6lgvit5r5blitjdgjrrkedmiyckblykchkzlfwc4.car')),
            "bafybeiajgoqpcayvds6lgvit5r5blitjdgjrrkedmiyckblykchkzlfwc4",
        )
    except Exception as e:
        print(f"Error occurred: {e}")

run(process_car_file())
# Error occurred: car stream for bafybeiajgoqpcayvds6lgvit5r5blitjdgjrrkedmiyckblykchkzlfwc4 not convertable to bytes

Note: the contents of the car file is two directory layers with a single file: bafybeiajgoqpcayvds6lgvit5r5blitjdgjrrkedmiyckblykchkzlfwc4/xm_data/p1/1700842786271269.parquet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.