Alex Litvinov
07/07/2023, 5:39 AMlangchain.document_loaders.GoogleDriveLoader
for that matters)
So I cannot just load the block and pass it directly
The workaround that I'm using is to
1. load the block
2. get the secret value
3. write it to a temp file
4. use it
temp_creds = tempfile.NamedTemporaryFile()
creds_dict = GcpCredentials.load("google-drive-creds").service_account_info.get_secret_value()
with open(temp_creds.name, 'w') as f_out:
json.dump(creds_dict, f_out)
loader = GoogleDriveLoader(service_account_key=Path(temp_creds.name),
document_ids=document_ids)
raw_docs = loader.load()
temp_creds.close()
To me this solution seems extremely ugly.
And my question is - is there a way to do it better?Nate
07/07/2023, 3:29 PMGoogleDriveLoader
class, since it requires you pass a path to the credentials file instead of also accepting the value
i might use a context manager for the temp file
creds_dict = GcpCredentials.load("google-drive-creds").service_account_info.get_secret_value()
with tempfile.NamedTemporaryFile(mode='w+') as temp_creds:
json.dump(creds_dict, temp_creds)
loader = GoogleDriveLoader(service_account_key=Path(temp_creds.name), document_ids=document_ids)
raw_docs = loader.load()
but is there something on the prefect side you'd like to see here?Alex Litvinov
07/09/2023, 8:02 AMhmm this strikes me as a restriction of theI agreeclassGoogleDriveLoader
but is there something on the prefect side you'd like to see here?not really, I think prefect is doing perfect in this instance 😀 just wanted to ask the community in case someone stumbled upon the same problem and found a more elegant solution.
i might use a context manager for the temp fileyup! makes sense Thanks @Nate!!!
Nate
07/10/2023, 1:45 AM❯ pip install git+<https://github.com/PrefectHQ/marvin.git>
Alex Litvinov
07/10/2023, 5:56 AM