Skip to content

Commit

Permalink
rm
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsleh committed Feb 19, 2025
1 parent c3e6617 commit 70fc4c7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
25 changes: 0 additions & 25 deletions tests/data/bigearthnet/v2/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import hashlib
import os
import shutil
import tarfile
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -191,30 +190,6 @@ def create_metadata() -> None:
df.to_parquet(os.path.join(ROOT_DIR, 'metadata.parquet'))


def compress_directory(dirname: str) -> None:
"""Compress directory using tar+zstd"""
tar_path = os.path.join(ROOT_DIR, f'{dirname}.tar')
with tarfile.open(tar_path, 'w') as tar:
tar.add(os.path.join(ROOT_DIR, dirname), arcname=dirname)

with open(tar_path, 'rb') as f_in:
data = f_in.read()
cctx = zstd.ZstdCompressor()
compressed = cctx.compress(data)
with open(f'{tar_path}.zst', 'wb') as f_out:
f_out.write(compressed)

os.remove(tar_path)

# print md5sum with hashlib
hash_md5 = hashlib.md5()
with open(f'{tar_path}.zst', 'rb') as f:
for chunk in iter(lambda: f.read(4096), b''):
hash_md5.update(chunk)

print(f'{tar_path}.zst: {hash_md5.hexdigest()}')


def main() -> None:
create_directory_structure()

Expand Down
10 changes: 1 addition & 9 deletions torchgeo/datasets/bigearthnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@

from .errors import DatasetNotFoundError
from .geo import NonGeoDataset
from .utils import (
Path,
download_url,
extract_archive,
lazy_import,
sort_sentinel2_bands,
)
from .utils import Path, download_url, extract_archive, sort_sentinel2_bands


class BigEarthNet(NonGeoDataset):
Expand Down Expand Up @@ -914,8 +908,6 @@ def _extract(self) -> None:
for key, meta in self.metadata_locs.items():
if key == 'metadata':
continue
assert not os.path.isdir(os.listdir(self.root)[2])
assert not os.path.isdir(os.path.join(self.root, 'BigEarthNet-S1.tar.gzaa'))
parts = [os.path.join(self.root, f) for f in meta['files'].keys()]
concat_path = os.path.join(self.root, self.dir_file_names[key] + '.tar.gz')
with open(concat_path, 'wb') as outfile:
Expand Down

0 comments on commit 70fc4c7

Please sign in to comment.