Skip to content

Testing applications that use fsspec.open("s3://...") #1785

Answered by dionhaefner
dionhaefner asked this question in Q&A
Discussion options

You must be logged in to vote

Example above is using mock_aws, which raises both with and without proxy mode (different errors tho).

Thanks for the pointer regarding global config though, that's helpful! This works now, even without monkeypatching anything:

import os
port = 5123
server_url = f"http://localhost:{port}"
os.environ["FSSPEC_S3_ENDPOINT_URL"] = server_url

import json
import boto3
import fsspec
from moto.server import ThreadedMotoServer

server = ThreadedMotoServer(port=port)
server.start()

client = boto3.client("s3", endpoint_url=server_url)
client.create_bucket(Bucket="test-bucket")

client.put_object(
    Bucket="test-bucket",
    Key="foo.json",
    Body=json.dumps({"inputs": "foo"}),
)

with fsspec.open

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@dionhaefner
Comment options

@martindurant
Comment options

@martindurant
Comment options

@dionhaefner
Comment options

Answer selected by dionhaefner
@martindurant
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants