-
Notifications
You must be signed in to change notification settings - Fork 16
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
Unit test Ceph cache and fix timezone awareness #2723
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
98034e8
Unit test Ceph cache and fix timezone awareness
mayaCostantini a13f693
Fix bucket prefix
mayaCostantini f96453b
Fix prefix not recognized in cluster tests
mayaCostantini 5bccc94
Add _DEPLOYMENT_NAME variable
mayaCostantini bffc989
Remove timeout > 2s
mayaCostantini 58089d7
Fix TTL value
mayaCostantini 4c942a7
Use timedelta
mayaCostantini 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
162 changes: 162 additions & 0 deletions
162
tests/data/result/adviser/adviser-220131050913-b7c4ef0fc532ac45
This file contains 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 |
---|---|---|
@@ -0,0 +1,162 @@ | ||
{ | ||
"metadata": { | ||
"analyzer": "thoth-adviser", | ||
"analyzer_version": "0.50.0", | ||
"arguments": { | ||
"advise": { | ||
"beam_width": 25000, | ||
"constraints": "input/constraints.txt", | ||
"count": 1, | ||
"dev": false, | ||
"labels": "input/labels.json", | ||
"library_usage": "input/library_usage.json", | ||
"limit": 1, | ||
"limit_latest_versions": -1, | ||
"no_pretty": false, | ||
"output": "/mnt/workdir/adviser-220131050913-b7c4ef0fc532ac45", | ||
"pipeline": null, | ||
"plot": null, | ||
"predictor": "AUTO", | ||
"predictor_config": {}, | ||
"prescription": [ | ||
"/opt/app-root/src/prescriptions.pickle" | ||
], | ||
"recommendation_type": "latest", | ||
"requirements": "input/Pipfile", | ||
"requirements_format": "pipenv", | ||
"requirements_locked": "input/Pipfile.lock", | ||
"runtime_environment": "input/runtime_environment.json", | ||
"seed": 42, | ||
"user_stack_scoring": true | ||
}, | ||
"thoth-adviser": { | ||
"metadata": { | ||
"kebechet_metadata": null, | ||
"origin": "https://github.com/thoth-station/ps-cv", | ||
"re_run_adviser_id": null, | ||
"source_type": null, | ||
"thoth.adviser": { | ||
"justification": null, | ||
"stack_info": null | ||
} | ||
}, | ||
"verbose": false | ||
} | ||
}, | ||
"datetime": "2022-01-31T05:15:49.969966", | ||
"distribution": { | ||
"codename": "Ootpa", | ||
"id": "rhel", | ||
"like": "fedora", | ||
"version": "8.3", | ||
"version_parts": { | ||
"build_number": "", | ||
"major": "8", | ||
"minor": "3" | ||
} | ||
}, | ||
"document_id": "adviser-220131050913-b7c4ef0fc532ac45", | ||
"duration": 376, | ||
"hostname": "adviser-220131050913-b7c4ef0fc532ac45-1876565397", | ||
"os_release": { | ||
"id": "rhel", | ||
"name": "Red Hat Enterprise Linux", | ||
"platform_id": "platform:el8", | ||
"redhat_bugzilla_product": "Red Hat Enterprise Linux 8", | ||
"redhat_bugzilla_product_version": "8.3", | ||
"redhat_support_product": "Red Hat Enterprise Linux", | ||
"redhat_support_product_version": "8.3", | ||
"version": "8.3 (Ootpa)", | ||
"version_id": "8.3" | ||
}, | ||
"python": { | ||
"api_version": 1013, | ||
"implementation_name": "cpython", | ||
"major": 3, | ||
"micro": 3, | ||
"minor": 8, | ||
"releaselevel": "final", | ||
"serial": 0 | ||
}, | ||
"thoth_deployment_name": "ocp4-stage", | ||
"timestamp": 1643606149 | ||
}, | ||
"result": { | ||
"error": true, | ||
"error_msg": "Resolver was killed as allocated memory has been exceeded (OOM) - https://thoth-station.ninja/j/oom", | ||
"parameters": { | ||
"beam_width": 25000, | ||
"constraints": "input/constraints.txt", | ||
"count": 1, | ||
"dev": false, | ||
"labels": {}, | ||
"library_usage": null, | ||
"limit": 1, | ||
"limit_latest_versions": -1, | ||
"no_pretty": false, | ||
"output": "/mnt/workdir/adviser-220131050913-b7c4ef0fc532ac45", | ||
"pipeline": null, | ||
"plot": null, | ||
"predictor": "AUTO", | ||
"predictor_config": "{}", | ||
"prescription": [ | ||
"/opt/app-root/src/prescriptions.pickle" | ||
], | ||
"project": { | ||
"constraints": [], | ||
"requirements": { | ||
"dev-packages": {}, | ||
"packages": { | ||
"jupyter-tensorboard": "*", | ||
"keras": "*", | ||
"opencv-python": "*", | ||
"pillow": "*", | ||
"tensorboard": "*", | ||
"tensorflow": ">=2.0.0" | ||
}, | ||
"requires": { | ||
"python_version": "3.8" | ||
}, | ||
"source": [ | ||
{ | ||
"name": "pypi", | ||
"url": "https://pypi.org/simple", | ||
"verify_ssl": true | ||
} | ||
] | ||
}, | ||
"requirements_locked": null, | ||
"runtime_environment": { | ||
"base_image": null, | ||
"cuda_version": null, | ||
"cudnn_version": null, | ||
"hardware": { | ||
"cpu_family": null, | ||
"cpu_model": null, | ||
"gpu_model": null | ||
}, | ||
"labels": null, | ||
"mkl_version": null, | ||
"name": "ps-cv-tensorflow", | ||
"openblas_version": null, | ||
"openmpi_version": null, | ||
"operating_system": { | ||
"name": "ubi", | ||
"version": "8" | ||
}, | ||
"platform": "linux-x86_64", | ||
"python_version": "3.8", | ||
"recommendation_type": null | ||
} | ||
}, | ||
"recommendation_type": "latest", | ||
"requirements": "input/Pipfile", | ||
"requirements_format": "pipenv", | ||
"requirements_locked": "input/Pipfile.lock", | ||
"runtime_environment": "input/runtime_environment.json", | ||
"seed": 42, | ||
"user_stack_scoring": true | ||
}, | ||
"report": null | ||
} | ||
} |
This file contains 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 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 | ||||
---|---|---|---|---|---|---|
|
@@ -18,6 +18,7 @@ | |||||
"""A base class for implementing caches based on Ceph.""" | ||||||
|
||||||
from datetime import datetime | ||||||
from datetime import timedelta | ||||||
from datetime import timezone | ||||||
|
||||||
from .exceptions import CacheMiss | ||||||
|
@@ -45,12 +46,11 @@ def retrieve_document_ttl(self, document_id: str) -> float: | |||||
self.retrieve_document_record(document_id) | ||||||
|
||||||
# Uses UTC time to be environment agnostic (no timezone) | ||||||
time_lived = ( | ||||||
datetime.now() | ||||||
- self.ceph.retrieve_document_attr(object_key=document_id, attr="LastModified").replace(tzinfo=timezone.utc) | ||||||
).total_seconds() | ||||||
time_lived = datetime.now(timezone.utc) - self.ceph.retrieve_document_attr( | ||||||
object_key=document_id, attr="LastModified" | ||||||
).replace(tzinfo=timezone.utc) | ||||||
|
||||||
if time_lived <= 14400.0: | ||||||
return time_lived | ||||||
if time_lived <= timedelta(hours=4): | ||||||
return (timedelta(hours=4) - time_lived).total_seconds() | ||||||
|
||||||
return 0.0 | ||||||
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.
Suggested change
Only if we switch to a timedelta return. |
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.
Could we return a timedelta object instead of a raw number of seconds ?
If not, I think we should at least use it internally to the function.