Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor kfp-api's ._context to property
Browse files Browse the repository at this point in the history
Moves definition of ._context from charm `init` to a property so that `._context` could include data not known during `init` (ex: relation or computed data)
ca-scribner committed Nov 17, 2023
1 parent 7251f8d commit f805a63
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions charms/kfp-api/src/charm.py
Original file line number Diff line number Diff line change
@@ -77,14 +77,6 @@ def __init__(self, *args):
self._database_name = "mlpipeline"
self._container = self.unit.get_container(self._container_name)

# setup context to be used for updating K8S resources
self._context = {
"app_name": self._name,
"namespace": self._namespace,
"service": self._name,
"grpc_port": self._grcp_port,
"http_port": self._http_port,
}
self._k8s_resource_handler = None

grpc_port = ServicePort(int(self._grcp_port), name="grpc-port")
@@ -160,6 +152,21 @@ def container(self):
"""Return container."""
return self._container

@property
def _context(self):
"""Return the context used for generating kubernetes resources."""
interfaces = self._get_interfaces()
os = self._get_object_storage(interfaces)

context = {
"app_name": self._name,
"namespace": self._namespace,
"service": self._name,
"grpc_port": self._grcp_port,
"http_port": self._http_port,
}
return context

@property
def k8s_resource_handler(self):
"""Update K8S with K8S resources."""

0 comments on commit f805a63

Please sign in to comment.