Skip to content

Commit

Permalink
Adapt the moved kafka-related files
Browse files Browse the repository at this point in the history
  • Loading branch information
aversey committed Jul 25, 2024
1 parent 30c2c56 commit f5a561e
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 7 deletions.
24 changes: 24 additions & 0 deletions python/hopsworks/core/kafka_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed 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 hopsworks_common.core.kafka_api import (
KafkaApi,
)


__all__ = [
KafkaApi,
]
24 changes: 24 additions & 0 deletions python/hopsworks/kafka_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed 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 hopsworks_common.kafka_schema import (
KafkaSchema,
)


__all__ = [
KafkaSchema,
]
24 changes: 24 additions & 0 deletions python/hopsworks/kafka_topic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2024 Hopsworks AB
#
# Licensed 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 hopsworks_common.kafka_topic import (
KafkaTopic,
)


__all__ = [
KafkaTopic,
]
30 changes: 27 additions & 3 deletions python/hopsworks_common/core/kafka_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
# limitations under the License.
#

from __future__ import annotations

import json
import socket
from typing import Any, Dict, Union

from hopsworks import client, constants, kafka_schema, kafka_topic
from hopsworks.client.exceptions import KafkaException
from hopsworks.client.external import Client
from hopsworks_common import client, constants, kafka_schema, kafka_topic
from hopsworks_common.client.exceptions import KafkaException
from hopsworks_common.client.external import Client


class KafkaApi:
Expand Down Expand Up @@ -383,3 +386,24 @@ def get_default_config(self):
)

return config

def get_subject(
self,
feature_store_id: int,
subject: str,
version: Union[str, int] = "latest",
) -> Dict[str, Any]:
_client = client.get_instance()
path_params = [
"project",
_client._project_id,
"featurestores",
feature_store_id,
"kafka",
"subjects",
subject,
"versions",
version,
]
headers = {"content-type": "application/json"}
return _client._send_request("GET", path_params, headers=headers)
4 changes: 2 additions & 2 deletions python/hopsworks_common/kafka_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import json

import humps
from hopsworks import util
from hopsworks.core import kafka_api
from hopsworks_common import util
from hopsworks_common.core import kafka_api


class KafkaSchema:
Expand Down
4 changes: 2 additions & 2 deletions python/hopsworks_common/kafka_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import json

import humps
from hopsworks import util
from hopsworks.core import kafka_api
from hopsworks_common import util
from hopsworks_common.core import kafka_api


class KafkaTopic:
Expand Down

0 comments on commit f5a561e

Please sign in to comment.