Skip to content

Commit

Permalink
Read file for import in one go
Browse files Browse the repository at this point in the history
Can not open as a stream because of DM-38589. Read the entire
file instead up front.
  • Loading branch information
timj committed Apr 10, 2023
1 parent 4cd4db0 commit c3ff71e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/lsst/daf/butler/_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import collections.abc
import contextlib
import io
import logging
import numbers
import os
Expand Down Expand Up @@ -2110,8 +2111,10 @@ def doImport(importStream: TextIO | ResourceHandleProtocol) -> None:
)

if isinstance(filename, ResourcePath):
with filename.open("r") as stream:
doImport(stream)
# We can not use open() here at the moment because of
# DM-38589 since yaml does stream.read(8192) in a loop.
stream = io.StringIO(filename.read().decode())
doImport(stream)
else:
doImport(filename)

Expand Down

0 comments on commit c3ff71e

Please sign in to comment.