-
Notifications
You must be signed in to change notification settings - Fork 1
SS-1380 MLFlow improvements #365
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
56a5905
SS-1380 MLFlow improvements
anondo1969 9a4c839
upgrading mlflow
anondo1969 7928ca4
adding specific exceptions
anondo1969 4e4f983
override upload_size field
anondo1969 64a70d1
Merge branch 'develop' into SS-1380_MLFlow_improvements
anondo1969 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import json | ||
| from datetime import datetime | ||
| from typing import Any, Optional | ||
| from typing import Any, Optional, Tuple | ||
|
|
||
| import regex as re | ||
| import requests | ||
|
|
@@ -10,6 +10,7 @@ | |
| from django.db import transaction | ||
| from django.forms.models import model_to_dict | ||
| from django.utils import timezone | ||
| from prometheus_client.parser import text_string_to_metric_families | ||
|
|
||
| from apps.constants import AppActionOrigin, HandleUpdateStatusResponseCode | ||
| from apps.types_.subdomain import SubdomainCandidateName | ||
|
|
@@ -756,3 +757,42 @@ def get_university_suffix_information(university_sufffix: str) -> str: | |
| } | ||
|
|
||
| return UNIVERSITY_NAMES.get(university_sufffix, university_sufffix) | ||
|
|
||
|
|
||
| def get_minio_usage(minio_service_name: str) -> Optional[Tuple[float, float]]: | ||
| metrics_url = f"http://{minio_service_name}/minio/v2/metrics/cluster" | ||
|
|
||
| try: | ||
| response = requests.get(metrics_url, timeout=5) | ||
| response.raise_for_status() | ||
| raw_metrics = response.text | ||
|
|
||
| except requests.RequestException as e: | ||
| logger.error(f"MinIO metrics url get request failed for {metrics_url}: {e}") | ||
| return None | ||
| except Exception as e: | ||
| logger.error(f"MinIO metrics fetch failed for {metrics_url}: {e}") | ||
| return None | ||
|
|
||
| # Helper to extract metric values | ||
| def get_metric_value(metric_name: str) -> float: | ||
| total = 0.0 | ||
| for family in text_string_to_metric_families(raw_metrics): | ||
| if family.name == metric_name: | ||
| total += sum(float(sample.value) for sample in family.samples) | ||
| return total | ||
|
|
||
| GIB_FACTOR = 1024**3 # 1 GiB in bytes | ||
|
|
||
| try: | ||
| used_bytes = get_metric_value("minio_cluster_usage_total_bytes") | ||
| total_bytes = get_metric_value("minio_cluster_capacity_usable_total_bytes") | ||
| except ValueError as e: | ||
| logger.error(f"MinIO metrics value parsing failed: {e}") | ||
| return None | ||
| except Exception as e: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here as as well, I'd say and have
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Added it. |
||
| logger.error(f"MinIO metrics parsing failed: {e}") | ||
| return None | ||
|
|
||
| # Convert to GiB and round | ||
| return (round(used_bytes / GIB_FACTOR, 2), round(total_bytes / GIB_FACTOR, 2)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to catch explicit requests exeception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Added it here.