Skip to content

Commit

Permalink
close temporary file for tox21molnet download before retrieving url
Browse files Browse the repository at this point in the history
  • Loading branch information
sfluegel committed Oct 1, 2024
1 parent e4caae8 commit 29cff11
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions chebai/preprocessing/datasets/tox21.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ def processed_file_names(self) -> List[str]:

def download(self) -> None:
"""Downloads and extracts the dataset."""
with NamedTemporaryFile("rb") as gout:
request.urlretrieve(
"https://deepchemdata.s3-us-west-1.amazonaws.com/datasets/tox21.csv.gz",
gout.name,
)
with gzip.open(gout.name) as gfile:
with open(os.path.join(self.raw_dir, "tox21.csv"), "wt") as fout:
fout.write(gfile.read().decode())
gout = NamedTemporaryFile("rb")
gout.close()

request.urlretrieve(
"https://deepchemdata.s3-us-west-1.amazonaws.com/datasets/tox21.csv.gz",
gout.name,
)
with gzip.open(gout.name) as gfile:
with open(os.path.join(self.raw_dir, "tox21.csv"), "wt") as fout:
fout.write(gfile.read().decode())

def setup_processed(self) -> None:
"""Processes and splits the dataset."""
Expand Down

0 comments on commit 29cff11

Please sign in to comment.