create new refresh token for googledrive

This commit is contained in:
rhythmcao
2024-03-02 21:08:53 +08:00
parent 196e20630b
commit 2aff825945
3 changed files with 15 additions and 10 deletions

View File

@@ -721,15 +721,20 @@ def get_number_of_search_results(env, config: Dict[str, str]):
def get_googledrive_file(env, config: Dict[str, Any]) -> str:
""" Get the desired file from Google Drive based on config, return the downloaded local filepath.
To retrieve the file, we provide two options in config dict:
1. query: a list of queries to search the file, each query is a string that follows the format of Google Drive search query
2. path: a list of path to the file, 'folder/subfolder/filename' -> ['folder', 'subfolder', 'filename']
3. query_list: query extends to list to download multiple files
4. path_list: path extends to list to download multiple files
dest: target file name or list. If *_list is used, dest should also be a list of the same length.
Return the downloaded filepath locally.
@args: keys in config dict
settings_file(str): target filepath to the settings file for Google Drive authentication, default is 'evaluation_examples/settings/googledrive/settings.yml'
query/path[_list](Union[str, List[str]]): the query or path [list] to the file(s) on Google Drive. To retrieve the file, we provide multiple key options to specify the filepath on drive in config dict:
1) query: a list of queries to search the file, each query is a string that follows the format of Google Drive search query. The documentation is available here: (support more complex search but too complicated to use)
https://developers.google.com/drive/api/guides/search-files?hl=en
2) path: a str list poingting to file path on googledrive, e.g., 'folder/subfolder/filename.txt' ->
config contain one key-value pair "path": ['folder', 'subfolder', 'filename.txt']
3) query_list: query extends to list to download multiple files
4) path_list: path extends to list to download multiple files, e.g.,
"path_list": [['folder', 'subfolder', 'filename1.txt'], ['folder', 'subfolder', 'filename2.txt']]
@return:
dest(Union[List[str], str]): target file name or list. If *_list is used in input config, dest should also be a list of the same length. Return the downloaded local filepath.
"""
settings_file = config.get('settings_file', 'evaluation_examples/settings/googledrive/settings.json')
settings_file = config.get('settings_file', 'evaluation_examples/settings/googledrive/settings.yml')
auth = GoogleAuth(settings_file=settings_file)
drive = GoogleDrive(auth)