@@ -72,8 +72,8 @@ def upload_directory_to_gcs(
72
72
# into hidden directories.
73
73
dirs [:] = [d for d in dirs if not d .startswith ("." )]
74
74
75
- # Keep only .md and .py files.
76
- files = [f for f in files if f .endswith (".md" ) or f . endswith ( ".py" )]
75
+ # Keep only .md, .py and .yaml files.
76
+ files = [f for f in files if f .endswith (( ".md" , ".py" , ".yaml" ) )]
77
77
78
78
for filename in files :
79
79
local_path = os .path .join (root , filename )
@@ -99,6 +99,19 @@ def upload_directory_to_gcs(
99
99
bucket .blob (gcs_path ).upload_from_string (
100
100
html_content , content_type = content_type
101
101
)
102
+ elif filename .lower ().endswith (".yaml" ):
103
+ # Vertex AI search doesn't recognize yaml,
104
+ # convert it to text and use text/plain instead
105
+ content_type = "text/plain"
106
+ with open (local_path , "r" , encoding = "utf-8" ) as f :
107
+ yaml_content = f .read ()
108
+ if not yaml_content :
109
+ print (" - Skipped empty file: " + local_path )
110
+ continue
111
+ gcs_path = gcs_path .removesuffix (".yaml" ) + ".txt"
112
+ bucket .blob (gcs_path ).upload_from_string (
113
+ yaml_content , content_type = content_type
114
+ )
102
115
else : # Python files
103
116
bucket .blob (gcs_path ).upload_from_filename (
104
117
local_path , content_type = content_type
0 commit comments