I've created a dagster resource using the new Pyth...
# ask-community
d
I've created a dagster resource using the new Pythonic resource method (extending ConfigurableResource), however the UI shows some of the secrets that I don't want displayed (ie user and password). What's the best method to create this resource without displaying those values? Code in 🧵
Copy code
class ArangoDbResource(ConfigurableResource):
    conn_strs: list[str]
    user: str
    password: str

    _arango_client: ArangoClient

    def setup_for_execution(self, context) -> None:
        self._arango_client = ArangoClient(hosts=self.conn_strs)

    def get_db(self, db_name: str):
        return self._arango_client.db(db_name, username=self.user, password=self.password)
s
Are you using the EnvVar function to load your environment variables? https://docs.dagster.io/guides/dagster/using-environment-variables-and-secrets#handling-secrets
this 1
d
I was not. We use env vars to set a key vault key value to load credentials. I was able to work around this using the following code for anyone facing a similar problem:
Copy code
class ArangoDbResource(ConfigurableResource):
    conn_strs_key: str
    creds_key: str
    
    _arango_client: ArangoClient
    _user: str
    _password : str

    def setup_for_execution(self, context) -> None:
        conn_strs = kv.f_get_secret(self.conn_strs_key)
        creds = kv.f_get_secret(self.creds_key)
        self._arango_client = ArangoClient(hosts=conn_strs)
        self._user = creds[0]
        self._password = creds[1]

    def get_db(self, db_name: str):
        return self._arango_client.db(db_name, username=self._user, password=self._password)

arangodb_resource = ArangoDbResource(conn_strs_key=EnvVar("ARANGO_CLUSTER_KEY"), creds_key=EnvVar("ARANGO_CRED_KEY"))
👏 1
Actually, now I'm getting this error...
Copy code
dagster._core.errors.DagsterSubprocessError: During multiprocess execution errors occurred in child processes:
In process 33: dagster._core.errors.DagsterInvalidInvocationError: 'ArangoDbResource' is a Pythonic resource and does not support manipulating undeclared attribute '_arango_client' as it inherits from 'pydantic.BaseModel' without extra="allow". If trying to maintain state on this resource, consider building a separate, stateful client class, and provide a method on the resource to construct and return the stateful client.
I'm not sure how to work around this?
Ah fixed it by making the private attributes = PrivateAttr()