Skip to content
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

Ensure dataset_lifetime bind is defined for DBS3Buffer/NewSubscription #11179

Merged
merged 1 commit into from
Jun 16, 2022

Conversation

amaltaro
Copy link
Contributor

Fixes #11178

Status

ready

Description

Make sure that bind dataset_lifetime is created when the SQL statement is executed. In case it's not defined, default to the same default value defined in the table schema creation (integer 0).

Is it backward compatible (if not, which system it affects?)

YES

Related PRs

Fixes a bug added in #11115

External dependencies / deployment changes

None

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 2 changes in unstable tests
  • Python3 Pylint check: failed
    • 3 warnings and errors that must be fixed
    • 6 comments to review
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13302/artifact/artifacts/PullRequestReport.html

@amaltaro amaltaro requested review from todor-ivanov and vkuznet June 10, 2022 13:25
@@ -39,6 +39,8 @@ def _createPhEDExSubBinds(self, datasetID, subscriptionInfo, custodialFlag):

# DeleteFromSource is not supported for move subscriptions
delete_blocks = None
# if None, force it to 0 as per the table schema
dataLifetime = subscriptionInfo['DatasetLifetime'] or 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer this syntax: dataLifetime = subscriptionInfo.get('DatasetLifetime', 0) It is safer since it checks if key exists in a dictionary, while in your case it can fail.

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 1 changes in unstable tests
  • Python3 Pylint check: failed
    • 3 warnings and errors that must be fixed
    • 6 comments to review
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/13304/artifact/artifacts/PullRequestReport.html

Copy link
Contributor

@todor-ivanov todor-ivanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Alan, The code looks good. I did leave a single comment inline, though. You may take a look if you like.

Thanks!

@@ -39,6 +39,8 @@ def _createPhEDExSubBinds(self, datasetID, subscriptionInfo, custodialFlag):

# DeleteFromSource is not supported for move subscriptions
delete_blocks = None
# if None, force it to 0 as per the table schema
dataLifetime = subscriptionInfo.get('DatasetLifetime', 0) or 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is quite ambiguous, I think. The .get() method is returning a proper default value, but we'd better have an explicit check for None value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@todor-ivanov you can see for your self:

# if you don't provide default value the type is None
>>> d={}
>>> d.get("foo")
>>> r=d.get("foo")
>>> type(r)
<class 'NoneType'>

# while if you provide default value the type is type of that value
>>> r=d.get("foo", 0)
>>> type(r)
<class 'int'>

Therefore, the line is correct, i.e. it is always return integer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vkuznet
I do see what the line is doing. I did not mean it is wrong. I simply wanted to say: The reader may just miss the fact that there is also another possibility the value to be None at first place - provided as such value from the dictionary itself. But as written here also works perfectly fine. Lets not waste time on such minor things. Forget about my comment @amaltaro. The code is good.

@amaltaro
Copy link
Contributor Author

Thanks for the review!

@amaltaro amaltaro merged commit cf69e5d into dmwm:master Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not all binds created for DBS3Buffer NewSubscription DAO
4 participants