-
Notifications
You must be signed in to change notification settings - Fork 13
configurable execution result store #29
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
Open
haileyok
wants to merge
15
commits into
main
Choose a base branch
from
hailey/configurable-execution-store
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ac05a60
make execution store configurable
haileyok 1ea7404
rm unnecessary optional type
haileyok d27951d
nit: naming
haileyok cd650af
tidy
haileyok ff5834d
nit: naming again
haileyok 9a23a78
type
haileyok a2ff50c
nit: naming yet again
haileyok 715a332
circular import
haileyok 29b89ec
type
haileyok c27f0b8
Update osprey_worker/src/osprey/worker/lib/storage/__init__.py
haileyok b50c895
Update osprey_worker/src/osprey/worker/lib/storage/__init__.py
haileyok 4833806
Update osprey_worker/src/osprey/worker/lib/storage/stored_execution_r…
haileyok 8d48923
more lower
haileyok 77d7607
Merge branch 'main' into hailey/configurable-execution-store
haileyok c1d8138
add back `trylast` to register
haileyok 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
43 changes: 43 additions & 0 deletions
43
osprey_worker/src/osprey/worker/_stdlibplugin/execution_result_store_chooser.py
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 |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| from typing import Optional | ||
|
|
||
| from osprey.worker.adaptor.plugin_manager import bootstrap_execution_result_store | ||
| from osprey.worker.lib.singletons import CONFIG | ||
| from osprey.worker.lib.storage import ExecutionResultStorageBackendType | ||
| from osprey.worker.lib.storage.stored_execution_result import ( | ||
| ExecutionResultStore, | ||
| StoredExecutionResultBigTable, | ||
| StoredExecutionResultGCS, | ||
| StoredExecutionResultMinIO, | ||
| ) | ||
|
|
||
|
|
||
| def get_rules_execution_result_storage_backend( | ||
| backend_type: ExecutionResultStorageBackendType, | ||
| ) -> Optional[ExecutionResultStore]: | ||
| """Based on the `backend_type` constructs a configured execution result store that can be used to store execution | ||
| results. For more details, see `ExecutionResultStore`.""" | ||
|
|
||
| config = CONFIG.instance() | ||
|
|
||
| if backend_type == ExecutionResultStorageBackendType.BIGTABLE: | ||
| return StoredExecutionResultBigTable() | ||
| elif backend_type == ExecutionResultStorageBackendType.GCS: | ||
| return StoredExecutionResultGCS() | ||
| elif backend_type == ExecutionResultStorageBackendType.MINIO: | ||
| endpoint = config.get_str('OSPREY_MINIO_ENDPOINT', 'minio:9000') | ||
| access_key = config.get_str('OSPREY_MINIO_ACCESS_KEY', 'minioadmin') | ||
| secret_key = config.get_str('OSPREY_MINIO_SECRET_KEY', 'minioadmin123') | ||
| secure = config.get_bool('OSPREY_MINIO_SECURE', False) | ||
| bucket_name = config.get_str('OSPREY_MINIO_EXECUTION_RESULTS_BUCKET', 'execution-output') | ||
|
|
||
| return StoredExecutionResultMinIO( | ||
| endpoint=endpoint, access_key=access_key, secret_key=secret_key, secure=secure, bucket_name=bucket_name | ||
| ) | ||
| elif backend_type == ExecutionResultStorageBackendType.PLUGIN: | ||
| store = bootstrap_execution_result_store(config=config) | ||
| if store is None: | ||
| raise AssertionError('No execution result store registered') | ||
| elif backend_type == ExecutionResultStorageBackendType.NONE: | ||
| return None | ||
|
|
||
| return None |
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
17 changes: 8 additions & 9 deletions
17
osprey_worker/src/osprey/worker/_stdlibplugin/storage_register.py
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,18 +1,17 @@ | ||
| from typing import Optional | ||
|
|
||
| from osprey.worker._stdlibplugin.execution_result_store_chooser import get_rules_execution_result_storage_backend | ||
| from osprey.worker.adaptor.plugin_manager import hookimpl_osprey | ||
| from osprey.worker.lib.config import Config | ||
| from osprey.worker.lib.storage.stored_execution_result import ExecutionResultStore, StoredExecutionResultMinIO | ||
| from osprey.worker.lib.storage import ExecutionResultStorageBackendType | ||
| from osprey.worker.lib.storage.stored_execution_result import ExecutionResultStore | ||
|
|
||
|
|
||
| @hookimpl_osprey(trylast=True) | ||
| def register_execution_result_store(config: Config) -> Optional[ExecutionResultStore]: | ||
| endpoint = config.get_str('OSPREY_MINIO_ENDPOINT', 'minio:9000') | ||
| access_key = config.get_str('OSPREY_MINIO_ACCESS_KEY', 'minioadmin') | ||
| secret_key = config.get_str('OSPREY_MINIO_SECRET_KEY', 'minioadmin123') | ||
| secure = config.get_bool('OSPREY_MINIO_SECURE', False) | ||
| bucket_name = config.get_str('OSPREY_MINIO_EXECUTION_RESULTS_BUCKET', 'execution-output') | ||
|
|
||
| return StoredExecutionResultMinIO( | ||
| endpoint=endpoint, access_key=access_key, secret_key=secret_key, secure=secure, bucket_name=bucket_name | ||
| storage_backend_type = ExecutionResultStorageBackendType( | ||
| config.get_str('OSPREY_EXECUTION_RESULT_STORAGE_BACKEND', 'none').lower() | ||
| ) | ||
| storage_backend = get_rules_execution_result_storage_backend(backend_type=storage_backend_type) | ||
|
|
||
| return storage_backend |
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,37 @@ | ||
| from enum import StrEnum, auto | ||
|
|
||
| # Import all models to ensure they're registered with SQLAlchemy | ||
| # This is required for metadata.create_all() to create all tables | ||
| from .bulk_action_task import BulkActionJob, BulkActionTask # noqa: F401 | ||
| from .bulk_label_task import BulkLabelTask # noqa: F401 | ||
| from .queries import Query, SavedQuery # noqa: F401 | ||
| from .temporary_ability_token import TemporaryAbilityToken # noqa: F401 | ||
|
|
||
|
|
||
| class ExecutionResultStorageBackendType(StrEnum): | ||
| """Type of store used for execution results.""" | ||
|
|
||
| BIGTABLE = auto() | ||
| """ | ||
| Bigtable execution result store | ||
| """ | ||
|
|
||
| GCS = auto() | ||
| """ | ||
| Google Cloud Storage execution result store | ||
| """ | ||
|
|
||
| MINIO = auto() | ||
| """ | ||
| Minio execution result store | ||
| """ | ||
|
|
||
| PLUGIN = auto() | ||
| """ | ||
| Execution result store that is defined via register_execution_result_store | ||
| """ | ||
|
|
||
| NONE = auto() | ||
| """ | ||
| Disable execution results from being stored. This may cause certain elements of Osprey to break, such as the events stream and individual event details in the UI | ||
| """ | ||
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 |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| from osprey.worker.lib.instruments import metrics | ||
| from osprey.worker.lib.osprey_shared.logging import get_logger | ||
| from osprey.worker.lib.snowflake import Snowflake | ||
| from osprey.worker.lib.storage import ExecutionResultStorageBackendType | ||
| from osprey.worker.lib.storage.bigtable import osprey_bigtable | ||
| from pydantic.main import BaseModel | ||
|
|
||
|
|
@@ -497,9 +498,17 @@ def get_many( | |
|
|
||
| def bootstrap_execution_result_storage_service() -> ExecutionResultStorageService: | ||
| """Create an ExecutionResultStorageService with the configured storage backend.""" | ||
| from osprey.worker.adaptor.plugin_manager import bootstrap_execution_result_store | ||
| from osprey.worker._stdlibplugin.execution_result_store_chooser import get_rules_execution_result_storage_backend | ||
| from osprey.worker.lib.singletons import CONFIG | ||
|
|
||
| config = CONFIG.instance() | ||
| storage_backend = bootstrap_execution_result_store(config) | ||
|
|
||
| storage_backend_type = ExecutionResultStorageBackendType( | ||
| config.get_str('OSPREY_EXECUTION_RESULT_STORAGE_BACKEND', 'none').lower() | ||
| ) | ||
| storage_backend = get_rules_execution_result_storage_backend(backend_type=storage_backend_type) | ||
|
|
||
| if storage_backend is None: | ||
| raise AssertionError('No storage backend registered') | ||
|
|
||
|
Comment on lines
+511
to
+513
Collaborator
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. afaict, it makes sense to raise here. the codepaths i see calling |
||
| return ExecutionResultStorageService(storage_backend) | ||
Oops, something went wrong.
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.
afaict, the ones i added here are the only ones that exist