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

Kuantifier Release Candidate Bugfixes #186

Merged

Conversation

mwestphall
Copy link
Contributor

  • Handle printing the env from a None envfile argument, which is the default
  • Update parsing of APEL records to handle cases where : is in the value (eg. SubmitHost: http://localhost:8000)
  • Round up processor count to the nearest integer rather than down (so 7.9 becomes 8 instead of 7)

@mwestphall mwestphall requested a review from brianhlin August 29, 2024 16:10
Copy link
Member

@brianhlin brianhlin left a comment

Choose a reason for hiding this comment

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

Some ideas -- preapproving

Comment on lines 55 to 57
def getint_roundup(self, key):
return int(float(self.apel_dict.get(key, 0)) + 0.5)

Copy link
Member

Choose a reason for hiding this comment

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

Does this actually work?

blin@blin-work:~$ python
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 13.2.1 20240316 (Red Hat 13.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> int(float(3.9))
3

Are you looking for math.ceiling() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This rounds >= X.5 to X +1, <= X.5 to X, eg:

>>> int(float("3.9") + .5)
4
>>> int(float("3.4") + .5)
3

. math.ceiling() is probably more appropriate though

Copy link
Member

Choose a reason for hiding this comment

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

Ah duh, that makes sense. math.ceiling doesn't do any sort of rounding so maybe what you had was right?

I'm not actually sure I understand what the ultimate goal is here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CPU requests are configured as 0.9 and 7.9 for 1 and 8 core jobs respectively in Armen's cluster to allow other small pods to run on the same node, which were getting truncated to 0 or 7 by this code. Either math.ceil or the +.5 trick will round them to 1 and 8 as desired in this case. I think math.ceil is slightly preferable since it will round a processor count of <0.5 to 1 instead of 0, but that is probably a rare corner case.

Copy link
Member

Choose a reason for hiding this comment

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

Huh and why do we need to turn this into an int?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good question. I looked at several sample gratia records while implementing this and noticed that all fields were integers, but never confirmed that that was actually a requirement

Comment on lines 47 to 48
# Handle case where apel values contain colons (eg. 'SubmitHost: http://localhost:8000')
kv_pair_match = re.match(r'([A-Za-z0-9_]+)\s*:\s*([^\s].*[^\s])\s*',line)
Copy link
Member

Choose a reason for hiding this comment

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

How about just limiting the number of splits?

>>> 'SubmitHost: http://localhost:8000'.split(':', maxsplit=1)
['SubmitHost', ' http://localhost:8000']

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't know about the maxsplit kwarg, that's very useful

@mwestphall mwestphall merged commit 71a1afd into opensciencegrid:2.x Aug 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants