-
Notifications
You must be signed in to change notification settings - Fork 551
Improve error message for duplicate pipeline run names #3701
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
+91
−5
Merged
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
c28564c
Improve error message for duplicate pipeline run names
strickvl 0b903f7
Add more specific examples to run_name documentation
strickvl 659288c
Fix mypy type errors for IntegrityError import
strickvl 3d2a22d
Address PR review comments for duplicate run name handling
strickvl 22bc668
Merge remote-tracking branch 'origin/develop' into feature/better-err…
strickvl 23bced4
Move duplicate run name error handling to SQLZenStore
strickvl 6dc98fe
Fix docstring linter error in create_placeholder_run
strickvl 508a616
Merge branch 'develop' into feature/better-error-message
htahir1 86307b4
Merge branch 'develop' into feature/better-error-message
htahir1 0e54848
Replace mocked test with integration test for duplicate pipeline runs
strickvl 816b870
Merge branch 'develop' into feature/better-error-message
strickvl b86a000
Fix SQLAlchemy autoflush issue in pipeline run creation
strickvl e86c84a
Clean up outdated comments in integration test
strickvl 419a8e8
Merge branch 'develop' into feature/better-error-message
strickvl 4ed0930
Refactor duplicate pipeline run name error handling
strickvl af7ae3c
Merge branch 'develop' into feature/better-error-message
strickvl 4bd95f2
Extract duplicate error message logic into helper method
strickvl 7b05e07
Update src/zenml/pipelines/run_utils.py
strickvl c15f153
Merge remote-tracking branch 'origin/develop' into feature/better-err…
strickvl 7bfe723
Merge branch 'develop' into feature/better-error-message
strickvl 03700a9
Merge branch 'develop' into feature/better-error-message
strickvl 8107860
Merge branch 'develop' into feature/better-error-message
strickvl 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
Some comments aren't visible on the classic Files Changed page.
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
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 |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| from zenml.config.source import Source, SourceType | ||
| from zenml.config.step_configurations import StepConfigurationUpdate | ||
| from zenml.enums import ExecutionStatus | ||
| from zenml.exceptions import EntityExistsError | ||
| from zenml.logger import get_logger | ||
| from zenml.models import ( | ||
| FlavorFilter, | ||
|
|
@@ -28,6 +29,14 @@ | |
| from zenml.utils.time_utils import utc_now | ||
| from zenml.zen_stores.base_zen_store import BaseZenStore | ||
|
|
||
| if TYPE_CHECKING: | ||
| from sqlalchemy.exc import IntegrityError as SQLIntegrityError | ||
| else: | ||
| try: | ||
| from sqlalchemy.exc import IntegrityError as SQLIntegrityError | ||
| except ImportError: | ||
| SQLIntegrityError = None | ||
|
|
||
| if TYPE_CHECKING: | ||
| StepConfigurationUpdateOrDict = Union[ | ||
| Dict[str, Any], StepConfigurationUpdate | ||
|
|
@@ -63,6 +72,10 @@ def create_placeholder_run( | |
|
|
||
| Returns: | ||
| The placeholder run or `None` if no run was created. | ||
|
|
||
| Raises: | ||
| EntityExistsError: If a pipeline run with the same name already exists, | ||
| with an improved error message suggesting solutions. | ||
| """ | ||
| assert deployment.user | ||
|
|
||
|
|
@@ -91,8 +104,51 @@ def create_placeholder_run( | |
| tags=deployment.pipeline_configuration.tags, | ||
| logs=logs, | ||
| ) | ||
| run, _ = Client().zen_store.get_or_create_run(run_request) | ||
| return run | ||
|
|
||
| try: | ||
|
||
| run, _ = Client().zen_store.get_or_create_run(run_request) | ||
| return run | ||
| except (EntityExistsError, RuntimeError) as e: | ||
| # Handle both EntityExistsError and raw database IntegrityError | ||
| original_message = str(e) | ||
|
|
||
| # Check for duplicate run name patterns in the error message | ||
| is_duplicate_run_name = False | ||
| run_name = run_request.name | ||
|
|
||
| # Check for ZenML's EntityExistsError | ||
| if isinstance(e, EntityExistsError) and ( | ||
| "pipeline run" in original_message.lower() | ||
| and "name" in original_message.lower() | ||
| ): | ||
| is_duplicate_run_name = True | ||
|
|
||
| # Check for raw SQL IntegrityError | ||
| elif ( | ||
| SQLIntegrityError is not None | ||
| and (isinstance(e.__cause__ or e, SQLIntegrityError)) | ||
| or "unique_run_name_in_project" in original_message | ||
| or ( | ||
| "duplicate entry" in original_message.lower() | ||
| and run_name in original_message | ||
| ) | ||
| ): | ||
| is_duplicate_run_name = True | ||
|
|
||
| if is_duplicate_run_name: | ||
| improved_message = ( | ||
| f"Pipeline run name '{run_name}' already exists in this project. " | ||
| f"Each pipeline run must have a unique name.\n\n" | ||
| f"To fix this, you can:\n" | ||
| f"1. Change the 'run_name' in your config file to a unique value\n" | ||
| f'2. Use a dynamic run name with placeholders like: run_name: "{run_name}_{{date}}_{{time}}"\n' | ||
| f"3. Remove the 'run_name' from your config to auto-generate unique names\n\n" | ||
| f"For more information on run naming, see: https://docs.zenml.io/concepts/steps_and_pipelines/yaml_configuration#run-name" | ||
| ) | ||
| raise EntityExistsError(improved_message) from e | ||
|
|
||
| # Re-raise the original error if it's not about duplicate run names | ||
| raise | ||
|
|
||
|
|
||
| def get_placeholder_run( | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.