Skip to content

Commit

Permalink
Merge pull request #76 from ExpediaGroup/track_client_id
Browse files Browse the repository at this point in the history
feat: Added client_id to registry request header
  • Loading branch information
vanitabhagwat authored Feb 2, 2024
2 parents 89d9ad5 + cd81739 commit b241c6a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions sdk/python/feast/infra/registry/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class HttpRegistryConfig(RegistryConfig):
""" str: Endpoint of Feature registry.
If registry_type is 'http', then this is a endpoint of Feature Registry """

client_id: Optional[StrictStr] = "Unknown"


CACHE_REFRESH_THRESHOLD_SECONDS = 300

Expand All @@ -77,10 +79,16 @@ def __init__(
timeout = httpx.Timeout(5.0, connect=60.0)
transport = httpx.HTTPTransport(retries=3, verify=False)
self.base_url = registry_config.path
headers_dict = {
"Content-Type": "application/json",
"Client-Id": registry_config.client_id,
}
headers = httpx.Headers(
{k: str(v) for k, v in headers_dict.items() if v is not None}
)

self.http_client = httpx.Client(
timeout=timeout,
transport=transport,
headers={"Content-Type": "application/json"},
timeout=timeout, transport=transport, headers=headers
)
self.project = project
self.apply_project(self.project)
Expand Down Expand Up @@ -145,6 +153,7 @@ def apply_entity(self, entity: Entity, project: str, commit: bool = True):
url = f"{self.base_url}/projects/{project}/entities"
data = EntityModel.from_entity(entity).json()
params = {"commit": commit}

response_data = self._send_request("PUT", url, params=params, data=data)
return EntityModel.parse_obj(response_data).to_entity()
except Exception as exception:
Expand Down
1 change: 1 addition & 0 deletions sdk/python/feast/repo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class RegistryConfig(FeastBaseModel):

s3_additional_kwargs: Optional[Dict[str, str]]
""" Dict[str, str]: Extra arguments to pass to boto3 when writing the registry file to S3. """
client_id: Optional[StrictStr] = "Unknown"


class RepoConfig(FeastBaseModel):
Expand Down

0 comments on commit b241c6a

Please sign in to comment.