Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update dependencies #50

Merged
merged 2 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions minato/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def get_lockfile_path(self, uid: str) -> Path:
def load_cached_file(self, metadata_path: Path) -> CachedFile:
if not metadata_path.exists():
raise CacheNotFoundError(f"Cache not found: {metadata_path}")
with open(metadata_path, "r") as fp:
with metadata_path.open("r") as fp:
params = json.load(fp)
return CachedFile(**params)

Expand All @@ -169,7 +169,7 @@ def exists(self, item: CachedFile) -> bool:

def save(self, item: CachedFile) -> None:
metadata_path = self.get_metadata_path(item.uid)
with open(metadata_path, "w") as fp:
with metadata_path.open("w") as fp:
json.dump(item.to_dict(), fp)

def add(self, item: CachedFile) -> CachedFile:
Expand All @@ -190,7 +190,7 @@ def by_uid(self, uid: str) -> CachedFile:
metadata_path = self.get_metadata_path(uid)
if not metadata_path.exists():
raise CacheNotFoundError(f"Cache not found with uid={uid}")
with open(metadata_path, "r") as fp:
with metadata_path.open("r") as fp:
params = json.load(fp)
return CachedFile(**params)

Expand Down Expand Up @@ -236,7 +236,7 @@ def is_expired(self, item: CachedFile) -> bool:
def all(self) -> List[CachedFile]:
cached_files: List[CachedFile] = []
for metafile_path in self._root.glob("*.json"):
with open(metafile_path, "r") as fp:
with metafile_path.open("r") as fp:
params = json.load(fp)
cached_file = CachedFile(**params)
cached_files.append(cached_file)
Expand Down
1 change: 0 additions & 1 deletion minato/filesystems/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def open_file(
*,
decompress: bool = False,
) -> ContextManager[IO[Any]]:

url = str(url_or_filename)
filesystem = FileSystem.by_url(url)
return filesystem.open_file(
Expand Down
1 change: 0 additions & 1 deletion minato/filesystems/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ def http_request_with_retry(
backoff_factor: int = 1,
allow_redirects: bool = False,
) -> http.client.HTTPResponse:

status_codes_to_retry = {502, 503, 504}
status_codes_to_redirect = {300, 301, 302, 303, 307, 308}

Expand Down
2 changes: 1 addition & 1 deletion minato/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def remove_file_or_directory(path: str | PathLike) -> None:
if path.is_dir():
shutil.rmtree(path)
else:
os.remove(path)
path.unlink()


def is_archive_file(filename: str | PathLike) -> bool:
Expand Down
356 changes: 162 additions & 194 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ keywords=["python", "cache", "s3", "google-cloud-storage"]

[tool.poetry.dependencies]
python = ">=3.8,<4.0"
boto3 = { version = "^1.0.0", optional = true }
google-cloud-storage = { version = "^1.0.0", optional = true }
boto3 = { version = ">=1.9.201,<2.0", optional = true }
google-cloud-storage = { version = ">=2.4,<3.0", optional = true }

[tool.poetry.dev-dependencies]
pytest = "^7.1.2"
python-language-server = "^0.36.2"
pysen = "^0.10.1"
black = "^22.3.0"
flake8 = "^4.0.1"
isort = "^5.10.1"
mypy = "^0.950"
moto = {version = "^2.0.9", extras = ["s3"]}
pytest = "^7.3.1"
pysen = "^0.10.4"
black = "^23.3.0"
isort = "^5.12.0"
flake8 = "^5.0.4"
mypy = "^1.2.0"
moto = {version = "^4.1.8", extras = ["s3"]}
boto3-stubs = {version = "^1.19.12", extras = ["s3"]}

[tool.poetry.extras]
Expand Down
4 changes: 2 additions & 2 deletions tests/filesystems/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_upload_file(tmpdir: Path) -> None:
conn.create_bucket(Bucket="my_bucket")

filename = tmpdir / "foo.txt"
with open(filename, "w") as localfile:
with filename.open("w") as localfile:
localfile.write("this is foo!")

fs = S3FileSystem("s3://my_bucket/dir/foo.txt")
Expand All @@ -187,7 +187,7 @@ def test_upload_file_to_dir(tmpdir: Path) -> None:
conn.create_bucket(Bucket="my_bucket")

filename = tmpdir / "foo.txt"
with open(filename, "w") as localfile:
with filename.open("w") as localfile:
localfile.write("this is foo!")

dirfs = S3FileSystem("s3://my_bucket/dir/")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_minato.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def test_upload(tmpdir: Path) -> None:
conn.create_bucket(Bucket="my_bucket")

filename = tmpdir / "local.txt"
with open(filename, "w") as localfile:
with filename.open("w") as localfile:
localfile.write("hello")

url = "s3://my_bucket/remote.txt"
Expand Down