jscheffl commented on code in PR #35612:
URL: https://github.com/apache/airflow/pull/35612#discussion_r1393330031
##########
setup.cfg:
##########
@@ -163,6 +163,7 @@ install_requires =
# See https://github.com/apache/airflow/pull/31693
# We should also remove "licenses/LICENSE-unicodecsv.txt" file when we
remove this dependency
unicodecsv>=0.14.1
+ universal_pathlib>=0.1.4
Review Comment:
I like the clean and lean interface of `upath` looking at the docs. But it
is v0.1.4 which sounds like very fesh and instable API. Are you sure it is a
good idea to set Airflow fundamental IO basics on a volatile base package? Are
there any mature alternatives so that we don't need to feat breaking APIs with
every update? (Just mainly asking for stability reasonst, not that I doubt that
functional it looks like a nice fit)
##########
airflow/io/path.py:
##########
@@ -0,0 +1,396 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import contextlib
+import functools
+import os
+import shutil
+import typing
+from pathlib import PurePath
+from urllib.parse import SplitResult, urlsplit
+
+from fsspec.core import split_protocol
+from fsspec.utils import stringify_path
+from upath.implementations.cloud import CloudPath, _CloudAccessor
+from upath.registry import get_upath_class
+
+from airflow.io.store import ObjectStore, attach
+from airflow.io.utils.stat import stat_result
+
+if typing.TYPE_CHECKING:
+ from fsspec import AbstractFileSystem
+
+
+PT = typing.TypeVar("PT", bound="ObjectStoragePath")
+
+default = "file"
+
+
+class _AirflowCloudAccessor(_CloudAccessor):
+ _store: ObjectStore
+ _conn_id: str | None
+
+ __slots__ = ("_store", "_conn_id")
+
+ def __init__(self, parsed_url: SplitResult | None, **kwargs: typing.Any)
-> None:
+ _store = kwargs.pop("store", None)
+ conn_id = kwargs.pop("conn_id", None)
+ if _store:
+ self._store = _store
+ elif parsed_url and parsed_url.scheme:
+ self._store = attach(parsed_url.scheme, conn_id) # todo add
kwargs as storage_options
+ else:
+ self._store = attach(default, conn_id)
+ self._conn_id = conn_id
+
+ @property
+ def _fs(self) -> AbstractFileSystem:
+ return self._store.fs
+
+ def __eq__(self, other):
+ return isinstance(other, _AirflowCloudAccessor) and self._store ==
other._store
+
+
+class ObjectStoragePath(CloudPath):
Review Comment:
In my previous comment I was thinking of shortening the name to
`StoragePath` but now one step later I realize this is really specific to all
sorts of object storage? Means I can not use this IO utility (anymore, compared
to previous version?) to also do IO operations on local files with the same API?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]