Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: add real paths column #1555

Merged
merged 4 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion xinference/core/cache_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from logging import getLogger
from typing import Any, Dict, List, Optional

Expand Down Expand Up @@ -105,9 +106,29 @@ def list_cached_models(self) -> List[Dict[Any, Any]]:
cached_models = []
for model_name, model_versions in self._model_name_to_version_info.items():
for version_info in model_versions:
if version_info["cache_status"]:
cache_status = version_info.get("cache_status", None)
if cache_status == True:
ret = version_info.copy()
ret["model_name"] = model_name

re_dict = version_info.get("model_file_location", None)
if re_dict is not None and isinstance(re_dict, dict):
if re_dict:
actor_ip_address, path = next(iter(re_dict.items()))
else:
raise ValueError("The dictionary is empty.")
else:
raise ValueError("re_dict must be a non-empty dictionary.")

ret["actor_ip_address"] = actor_ip_address
ret["path"] = path
if os.path.isdir(path):
files = os.listdir(path)
resolved_file = os.path.realpath(os.path.join(path, files[0]))
if resolved_file:
ret["real_path"] = os.path.dirname(resolved_file)
else:
ret["real_path"] = os.path.realpath(path)
cached_models.append(ret)
cached_models = sorted(cached_models, key=lambda x: x["model_name"])
return cached_models
6 changes: 4 additions & 2 deletions xinference/core/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,9 @@ async def list_cached_models(self) -> List[Dict[str, Any]]:
"model_size_in_billions", None
)
quantizations = model_version.get("quantization", None)
re_dict = model_version.get("model_file_location", None)
actor_ip_address, path = next(iter(re_dict.items()))
actor_ip_address = model_version.get("actor_ip_address", None)
path = model_version.get("path", None)
real_path = model_version.get("real_path", None)

cache_entry = {
"model_name": model_name,
Expand All @@ -1003,6 +1004,7 @@ async def list_cached_models(self) -> List[Dict[str, Any]]:
"quantizations": quantizations,
"path": path,
"Actor IP Address": actor_ip_address,
"real_path": real_path,
}

cached_models.append(cache_entry)
Expand Down
Loading