File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -563,6 +563,8 @@ class HTTPSource(uproot.source.chunk.Source):
563
563
ResourceClass = HTTPResource
564
564
565
565
def __init__ (self , file_path : str , ** options ):
566
+ options = dict (uproot .reading .open .defaults , ** options )
567
+
566
568
self ._num_fallback_workers = options ["num_fallback_workers" ]
567
569
self ._timeout = options ["timeout" ]
568
570
self ._num_requests = 0
@@ -607,7 +609,7 @@ def __repr__(self):
607
609
if len (self ._file_path ) > 10 :
608
610
path = repr ("..." + self ._file_path [- 10 :])
609
611
fallback = ""
610
- if self ._fallback is not None :
612
+ if hasattr ( self , "_fallback" ) and self ._fallback is not None :
611
613
fallback = " with fallback"
612
614
return f"<{ type (self ).__name__ } { path } { fallback } at 0x{ id (self ):012x} >"
613
615
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ def __init__(
42
42
):
43
43
Minio = uproot .extras .Minio_client ()
44
44
45
+ self ._file_path = file_path
45
46
if access_key is None :
46
47
access_key = os .environ .get (
47
48
"S3_ACCESS_KEY" , os .environ .get ("AWS_ACCESS_KEY_ID" , None )
Original file line number Diff line number Diff line change 9
9
10
10
@pytest .mark .network
11
11
def test_s3_fail ():
12
- with pytest .raises (Exception ):
13
- with uproot .source .http .S3Source (
12
+ with pytest .raises (FileNotFoundError ):
13
+ with uproot .source .s3 .S3Source (
14
14
"s3://pivarski-princeton/does-not-exist" , timeout = 0.1
15
15
) as source :
16
- tobytes (source .chunk (0 , 100 ).raw_data )
16
+ uproot . _util . tobytes (source .chunk (0 , 100 ).raw_data )
17
17
18
18
19
19
@pytest .mark .network
20
20
def test_read_s3 ():
21
21
with uproot .open (
22
- "s3://pivarski-princeton/pythia_ppZee_run17emb.picoDst.root:PicoDst"
22
+ "s3://pivarski-princeton/pythia_ppZee_run17emb.picoDst.root:PicoDst" ,
23
+ handler = uproot .source .s3 .S3Source ,
23
24
) as f :
24
25
data = f ["Event/Event.mEventId" ].array (library = "np" )
25
26
assert len (data ) == 8004
You can’t perform that action at this time.
0 commit comments