|
5 | 5 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ |
6 | 6 |
|
7 | 7 | import json |
| 8 | +import logging |
8 | 9 | import os |
9 | | -from functools import lru_cache |
10 | 10 | from typing import Dict, Tuple |
11 | | -import logging |
12 | 11 |
|
13 | 12 | import fsspec |
14 | | -import requests |
15 | 13 | import yaml |
16 | 14 | from cerberus import DocumentError, Validator |
17 | 15 |
|
18 | 16 | from ads.common.object_storage_details import ObjectStorageDetails |
19 | | -from ads.common.utils import PAR_LINK |
20 | 17 |
|
21 | 18 | MODEL_PROVENANCE_SCHEMA_PATH = os.path.join( |
22 | 19 | os.path.dirname(os.path.abspath(__file__)), |
@@ -127,8 +124,8 @@ def _get_index_json_through_bucket( |
127 | 124 | service_packs = json.loads(f.read()) |
128 | 125 | service_pack_list = service_packs.get(SERVICE_PACKS) |
129 | 126 | except Exception as e: |
130 | | - logging.warn(e) |
131 | | - logging.warn( |
| 127 | + logging.warning(e) |
| 128 | + logging.warning( |
132 | 129 | "Failed to retrieve the full conda pack path from slug. Pass conda pack path 'oci://<bucketname>@<namespace>/<path_to_conda>' instead of slug." |
133 | 130 | ) |
134 | 131 | return service_pack_list |
@@ -160,21 +157,15 @@ def get_service_packs( |
160 | 157 | service_pack_path_mapping = {} |
161 | 158 | service_pack_slug_mapping = {} |
162 | 159 | try: |
163 | | - response = requests.request("GET", PAR_LINK) |
164 | | - |
165 | | - # if there is internet |
166 | | - if response.ok: |
167 | | - service_pack_list = response.json().get(SERVICE_PACKS) |
168 | | - # response not good. |
169 | | - else: |
170 | | - service_pack_list = _get_index_json_through_bucket( |
171 | | - namespace=namespace, bucketname=bucketname, auth=auth |
172 | | - ) |
173 | | - except Exception as e: |
174 | | - # not internet |
| 160 | + logging.info("Obtaining service packs through bucket.") |
175 | 161 | service_pack_list = _get_index_json_through_bucket( |
176 | 162 | namespace=namespace, bucketname=bucketname, auth=auth |
177 | 163 | ) |
| 164 | + except Exception as e: |
| 165 | + # not internet |
| 166 | + logging.warning(e) |
| 167 | + logging.warning("Failed to obtain service packs through bucket. Please ensure internet connection.") |
| 168 | + |
178 | 169 |
|
179 | 170 | for service_pack in service_pack_list: |
180 | 171 | # Here we need to replace the namespace and bucketname |
|
0 commit comments