How do I get Vertex AI pipelines to see cloudshell files?

Viewed 48

I am running a vertex AI pipeline, from Cloudshell:

  if __name__ == '__main__':
    sfile= open("/path/to/keyfile.json", "r")
    compile()
    trigger_pipeline()

I have declared sfile here because by the time I get to the component, the file system no longer sees the file (God knows why):

@component(
     packages_to_install=['google-cloud-secret-manager']
 )
def print_secret_op(project_id: str, secret_id: str, version_id: str) -> str:    
    from google.cloud import secretmanager
    from google.oauth2 import service_account
    
    credentials = service_account.Credentials.from_service_account_file(sfile)

but here sfile doesn't have a value and I don't know how to pass it in (I can pass the file path but for some reason the home folder is empty at this stage). How can I pass the file into this, or why can the file no longer be seen at this point? (I tried declaring sfile at the start of the python program but the component still couldn't see it.)

1 Answers
Related