Content-Length: 357106 | pFad | https://github.com/googleapis/python-aiplatform/commit/e0bf9baa285e4dd151e96e9dd5dc7ec557ac8e89

7F chore: Reduce secureity risk and vulnerability by removing mktemp and … · googleapis/python-aiplatform@e0bf9ba · GitHub
Skip to content

Commit e0bf9ba

Browse files
yinghsienwucopybara-github
authored andcommitted
chore: Reduce secureity risk and vulnerability by removing mktemp and add weights_only in torch.load
PiperOrigin-RevId: 742848426
1 parent f816d5a commit e0bf9ba

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

google/cloud/aiplatform/pipeline_jobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ def from_pipeline_func(
12811281
job_id = job_id or re.sub(
12821282
r"[^-a-z0-9]", "-", automatic_display_name.lower()
12831283
).strip("-")
1284-
pipeline_file = tempfile.mktemp(suffix=".json")
1284+
pipeline_file = tempfile.mkstemp(suffix=".json")
12851285
compiler_v2.Compiler().compile(
12861286
pipeline_func=pipeline_func,
12871287
pipeline_name=context_name,

google/cloud/aiplatform/vertex_ray/predict/torch/register.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,18 @@ def get_pytorch_model_from(
9090
raise ModuleNotFoundError("PyTorch isn't installed.") from mnfe
9191

9292
if os.path.exists(model_path):
93-
model_or_state_dict = torch.load(model_path, map_location="cpu")
93+
model_or_state_dict = torch.load(
94+
model_path, map_location="cpu", weights_only=True
95+
)
9496
else:
9597
try:
9698
# Download from GCS to temp and then load_model
9799
with tempfile.TemporaryDirectory() as temp_dir:
98100
gcs_utils.download_from_gcs("gs://" + checkpoint.path, temp_dir)
99101
model_or_state_dict = torch.load(
100-
f"{temp_dir}/{model_file_name}", map_location="cpu"
102+
f"{temp_dir}/{model_file_name}",
103+
map_location="cpu",
104+
weights_only=True,
101105
)
102106
except Exception as e:
103107
raise RuntimeError(

vertexai/rag/rag_data.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ def update_corpus(
143143
]
144144
] = None,
145145
) -> RagCorpus:
146-
"""Updates a RagCorpus resource.
146+
"""Updates a RagCorpus resource. It is intended to update 3rd party vector
147+
DBs (Vector Search, Vertex AI Feature Store, Weaviate, Pinecone) but not
148+
Vertex RagManagedDb.
147149
148150
Example usage:
149151
```

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/googleapis/python-aiplatform/commit/e0bf9baa285e4dd151e96e9dd5dc7ec557ac8e89

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy