-
Notifications
You must be signed in to change notification settings - Fork 3
#598 Add '--skip-locked' option so that already running jobs are skipped instead of error thrown #600
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
#598 Add '--skip-locked' option so that already running jobs are skipped instead of error thrown #600
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
20 changes: 20 additions & 0 deletions
20
.../core/src/main/scala/za/co/absa/pramen/core/runner/task/AlreadyRunningSkipException.scala
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,20 @@ | ||
/* | ||
* Copyright 2022 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* 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. | ||
*/ | ||
|
||
package za.co.absa.pramen.core.runner.task | ||
|
||
/** This exception is used only for gracefully skipping jobs that are already running. */ | ||
class AlreadyRunningSkipException extends RuntimeException("Another instance is already running") |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
💡 Verification agent
🧩 Analysis chain
Verify configuration key consistency.
The configuration key looks correct, but ensure it matches the key defined in
reference.conf
.🏁 Script executed:
Length of output: 69
🏁 Script executed:
Length of output: 1713
🏁 Script executed:
Length of output: 1682
Missing configuration key in reference.conf
The constant
SKIP_LOCKED = "pramen.runtime.skip.locked"
isn’t defined in any of yourreference.conf
files. Please add this key (with a default value) so that the setting is recognized at runtime.Locations to update:
Suggested diff for
pramen/core/src/main/resources/reference.conf
:🤖 Prompt for AI Agents
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.
The default configuration is there in reference.conf. The line is 'runtime.skip.locked = false'. It is under 'pramen { }' section.
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.
🧩 Analysis chain
🏁 Script executed:
Length of output: 3819
@yruslan You're absolutely right, and I apologize for the confusion! The configuration key
runtime.skip.locked = false
is indeed present inpramen/core/src/main/resources/reference.conf
under thepramen { }
section, exactly as you stated.I can see from the search results that it's properly configured:
My initial analysis was incorrect - I was searching for the fully qualified dotted notation
"pramen.runtime.skip.locked"
but HOCON configuration files use nested structures. When nested under thepramen { }
section asruntime.skip.locked = false
, it's correctly accessible via the flat key"pramen.runtime.skip.locked"
that yourRuntimeConfig.fromConfig
method uses.Thank you for the correction! The configuration setup is working as intended.
🐰
(\ /)
( ..)
o(")(") learns something new
🧬 Code Graph Analysis Results
Relevant snippet from
pramen/core/src/main/scala/za/co/absa/pramen/core/app/config/RuntimeConfig.scala
(lines 1-153)This file defines the
RuntimeConfig
case class and its companion object which handles loading runtime configuration from a TypesafeConfig
object.The
RuntimeConfig
case class contains many fields controlling runtime behavior, including:skipLocked: Boolean
— whether to skip jobs that are already running and holding a lock.useLocks: Boolean
— whether to acquire locks before writing.isDryRun
,isRerun
,isUndercover
,checkOnlyLateData
,checkOnlyNewData
, etc.runDate
andrunDateTo
for specifying the date range.parallelTasks
,stopSparkSession
,allowEmptyPipeline
,alwaysAddBatchIdColumn
,historicalRunMode
, andsparkAppDescriptionTemplate
.The companion object defines string constants for config keys, including:
SKIP_LOCKED = "pramen.runtime.skip.locked"
USE_LOCK = "pramen.use.lock"
DRY_RUN
,IS_RERUN
,RUN_TABLES
, etc.The
fromConfig(conf: Config): RuntimeConfig
method reads the configuration from the providedConfig
object:skipLocked
usingconf.getBoolean(SKIP_LOCKED)
.useLocks
usingconf.getBoolean(USE_LOCK)
.ConfigUtils
to read optional values.LocalDate
usingconvertStrToDate
.parallelTasks
is zero or negative.RuntimeConfig
instance.The
default
method returns aRuntimeConfig
instance with hardcoded default values, including:skipLocked = false
useLocks = true
isDryRun = false
isRerun = false
parallelTasks = 1
stopSparkSession = true
historicalRunMode = RunMode.CheckUpdates
This file is the primary place where the runtime configuration is loaded and interpreted, including the
skipLocked
flag mentioned in the user comment.Relevant snippet from
pramen/core/src/main/scala/za/co/absa/pramen/core/utils/ConfigUtils.scala
(lines 30-80 approx)This utility object provides helper methods to safely read optional configuration values from a Typesafe
Config
object:getOptionBoolean(conf: Config, path: String): Option[Boolean]
— returnsSome(boolean)
if the path exists, elseNone
.getOptionString(conf: Config, path: String): Option[String]
— returnsSome(string)
if the path exists, elseNone
.getOptListStrings(conf: Config, path: String): Seq[String]
— returns a list of strings if the path exists, else empty list.These methods are used in
RuntimeConfig.fromConfig
to read optional config keys safely.Relevant snippet from
pramen/api/src/main/scala/za/co/absa/pramen/api/RunMode.scala
(lines 20-45)Defines the
RunMode
sealed trait and its three case objects:SkipAlreadyRan
("fill_gaps")CheckUpdates
("check_updates")ForceRun
("force")Includes a method
fromString
to parse a string into aRunMode
.This is relevant because
RuntimeConfig
usesRunMode
for thehistoricalRunMode
field and parses it from config key"pramen.runtime.run.mode"
.Summary
The key relevant information for the user comment about the default configuration line
runtime.skip.locked = false
under thepramen { }
section is:RuntimeConfig
object reads theskipLocked
flag from the config key"pramen.runtime.skip.locked"
.skipLocked
in thedefault
method isfalse
.pramen
namespace, consistent with the user comment.fromConfig
method reads this flag directly from the providedConfig
object, which would typically be loaded fromreference.conf
or other config files.[no additional relevant snippets found]