Zach
08/05/2023, 12:12 AMsetup_for_execution
method where it is trying to use methods on the inner resource, but it appears that the inner resource hasn't been initialized, so I end up with "Missing self" parameter errors.
Here's what I'm working with:
class OauthCredsResolver(ConfigurableResource):
oauth_client_id_param: str = "/databricks/service-principal/etx-automaton/client_id"
oauth_client_secret_param: str = (
"/databricks/service-principal/etx-automaton/secret"
)
ssm_resource: SSMResource
_oauth_client_id = PrivateAttr()
_oauth_client_secret = PrivateAttr()
def setup_for_execution(self, context: InitResourceContext):
self._oauth_client_id = self.ssm_resource.get_parameter(
Name=self.oauth_client_id_param, WithDecryption=True
)
self._oauth_client_secret = self.ssm_resource.get_parameter(
Name=self.oauth_client_secret_param, WithDecryption=True
)
@classmethod
def get_oauth_creds(self):
return OauthCreds(
oauth_client_id=self._oauth_client_id,
oauth_secret=self._oauth_client_secret,
)
class DatabricksWorkspaceClient(ConfigurableResource):
databricks_host: str = "<https://empiricotx.cloud.databricks.com>"
oauth_creds_resolver = OauthCredsResolver
_client: WorkspaceClient = PrivateAttr()
def setup_for_execution(self, context: InitResourceContext) -> None:
oauth_creds = self.oauth_creds_resolver.get_oauth_creds()
<http://context.log.info|context.log.info>(f"oauth_client_id: {oauth_creds.oauth_client_id}")
self._client = WorkspaceClient(
host=self.databricks_host,
client_id=oauth_creds.oauth_client_id,
client_secret=oauth_creds.oauth_secret,
)
@property
def client(self) -> WorkspaceClient:
return self._client
when self.oauth_creds_resolver.get_oauth_creds()
runs I get TypeError: get_oauth_creds() missing 1 required positional argument: 'self'
, indicating that the object hasn't been initialized and I actually have some kind of class handle.
One more details is that this resource is being used in an op via .from_resource_context(context)
- I'm guessing maybe that has something to do with it