-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add get fileset context api in python client
- Loading branch information
xiaojiebao
committed
Aug 5, 2024
1 parent
2608f5a
commit ebf6ed7
Showing
13 changed files
with
509 additions
and
1 deletion.
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
47 changes: 47 additions & 0 deletions
47
clients/client-python/gravitino/api/base_fileset_data_operation_ctx.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# 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 gravitino.api.client_type import ClientType | ||
from gravitino.api.fileset_data_operation import FilesetDataOperation | ||
from gravitino.api.fileset_data_operation_ctx import FilesetDataOperationCtx | ||
|
||
|
||
class BaseFilesetDataOperationCtx(FilesetDataOperationCtx): | ||
"""Base implementation of FilesetDataOperationCtx.""" | ||
|
||
_sub_path: str | ||
_operation: FilesetDataOperation | ||
_client_type: ClientType | ||
|
||
def __init__( | ||
self, sub_path: str, operation: FilesetDataOperation, client_type: ClientType | ||
): | ||
assert sub_path is not None | ||
assert operation is not None | ||
assert client_type is not None | ||
self._sub_path = sub_path | ||
self._operation = operation | ||
self._client_type = client_type | ||
|
||
def sub_path(self) -> str: | ||
return self._sub_path | ||
|
||
def operation(self) -> FilesetDataOperation: | ||
return self._operation | ||
|
||
def client_type(self) -> ClientType: | ||
return self._client_type |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 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 enum import Enum | ||
|
||
|
||
class ClientType(Enum): | ||
"""An enum class containing fileset data operations client type that supported.""" | ||
|
||
PYTHON_GVFS = 1 | ||
UNKNOWN = 2 |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# 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 abc import ABC, abstractmethod | ||
|
||
from gravitino.api.fileset import Fileset | ||
|
||
|
||
class FilesetContext(ABC): | ||
"""An interface representing a fileset context with an existing fileset. This | ||
interface defines some contextual information related to Fileset that can be passed. | ||
""" | ||
|
||
@abstractmethod | ||
def fileset(self) -> Fileset: | ||
"""The fileset object. | ||
Returns: | ||
the fileset object. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def actual_path(self) -> str: | ||
"""The actual storage path after processing. | ||
Returns: | ||
the actual storage path after processing. | ||
""" | ||
pass |
38 changes: 38 additions & 0 deletions
38
clients/client-python/gravitino/api/fileset_data_operation.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 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 enum import Enum | ||
|
||
|
||
class FilesetDataOperation(Enum): | ||
"""An enum class containing fileset data operations that supported.""" | ||
|
||
LIST_STATUS = 1 | ||
GET_FILE_STATUS = 2 | ||
EXISTS = 3 | ||
RENAME = 4 | ||
APPEND = 5 | ||
CREATE = 6 | ||
DELETE = 7 | ||
OPEN = 8 | ||
MKDIRS = 9 | ||
CREATED_TIME = 10 | ||
MODIFIED_TIME = 11 | ||
COPY_FILE = 12 | ||
CAT_FILE = 13 | ||
GET_FILE = 14 | ||
UNKNOWN = 15 |
54 changes: 54 additions & 0 deletions
54
clients/client-python/gravitino/api/fileset_data_operation_ctx.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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# 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 abc import ABC, abstractmethod | ||
|
||
from gravitino.api.client_type import ClientType | ||
from gravitino.api.fileset_data_operation import FilesetDataOperation | ||
|
||
|
||
class FilesetDataOperationCtx(ABC): | ||
"""An interface representing a fileset data operation context. This interface defines some | ||
information need to report to the server. | ||
""" | ||
|
||
@abstractmethod | ||
def sub_path(self) -> str: | ||
"""The sub path which is operated by the data operation. | ||
Returns: | ||
the sub path which is operated by the data operation. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def operation(self) -> FilesetDataOperation: | ||
"""The data operation type. | ||
Returns: | ||
the data operation type. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def client_type(self) -> ClientType: | ||
"""The client type of the data operation. | ||
Returns: | ||
the client type of the data operation. | ||
""" | ||
pass |
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
38 changes: 38 additions & 0 deletions
38
clients/client-python/gravitino/dto/fileset_context_dto.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 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 abc import ABC | ||
from dataclasses import dataclass, field | ||
|
||
from dataclasses_json import config, DataClassJsonMixin | ||
|
||
from gravitino.api.fileset_context import FilesetContext | ||
from gravitino.dto.fileset_dto import FilesetDTO | ||
|
||
|
||
@dataclass | ||
class FilesetContextDTO(FilesetContext, DataClassJsonMixin, ABC): | ||
"""Represents a Fileset Context DTO (Data Transfer Object).""" | ||
|
||
_fileset: FilesetDTO = field(metadata=config(field_name="fileset")) | ||
_actual_path: str = field(metadata=config(field_name="actualPath")) | ||
|
||
def fileset(self) -> FilesetDTO: | ||
return self._fileset | ||
|
||
def actual_path(self) -> str: | ||
return self._actual_path |
45 changes: 45 additions & 0 deletions
45
clients/client-python/gravitino/dto/requests/get_fileset_context_request.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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 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 dataclasses import dataclass, field | ||
from dataclasses_json import config | ||
|
||
from gravitino.api.client_type import ClientType | ||
from gravitino.api.fileset_data_operation import FilesetDataOperation | ||
from gravitino.rest.rest_message import RESTRequest | ||
|
||
|
||
@dataclass | ||
class GetFilesetContextRequest(RESTRequest): | ||
"""Request to represent to get a fileset context.""" | ||
|
||
_sub_path: str = field(metadata=config(field_name="subPath")) | ||
_operation: FilesetDataOperation = field(metadata=config(field_name="operation")) | ||
_client_type: ClientType = field(metadata=config(field_name="clientType")) | ||
|
||
def __init__( | ||
self, sub_path: str, operation: FilesetDataOperation, client_type: ClientType | ||
): | ||
self._sub_path = sub_path | ||
self._operation = operation | ||
self._client_type = client_type | ||
self.validate() | ||
|
||
def validate(self): | ||
assert self._sub_path is not None, "subPath is required" | ||
assert self._operation is not None, "operation is required" | ||
assert self._client_type is not None, "clientType is required" |
Oops, something went wrong.