-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ingestion): provide better names, add kwargs param to create method
- Loading branch information
oleksandrsimonchuk
committed
Oct 6, 2023
1 parent
99c09d1
commit c57d12c
Showing
6 changed files
with
39 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
metadata-ingestion/src/datahub/ingestion/source/fs/http_fs.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
import requests | ||
import smart_open | ||
from typing import Iterable | ||
from datahub.ingestion.source.fs.fs_base import FileSystem, FileStatus | ||
from datahub.ingestion.source.fs.fs_base import FileSystem, FileInfo | ||
|
||
|
||
class HttpFileSystem(FileSystem): | ||
|
||
@classmethod | ||
def create_fs(cls): | ||
def create(cls, **kwargs): | ||
return HttpFileSystem() | ||
|
||
def open(self, path: str, **kwargs): | ||
return smart_open.open(path, mode='rb', transport_params=kwargs) | ||
|
||
def file_status(self, path: str) -> FileStatus: | ||
def file_status(self, path: str) -> FileInfo: | ||
head = requests.head(path) | ||
if head.ok: | ||
return FileStatus(path, int(head.headers['Content-length']), is_file=True) | ||
return FileInfo(path, int(head.headers['Content-length']), is_file=True) | ||
elif head.status_code == 404: | ||
raise Exception(f"Requested path {path} does not exists.") | ||
else: | ||
raise Exception(f"Cannot get file status for the requested path {path}.") | ||
|
||
def list(self, path: str) -> Iterable[FileStatus]: | ||
def list(self, path: str) -> Iterable[FileInfo]: | ||
status = self.file_status(path) | ||
return [status] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters