Skip to content

Commit dec3739

Browse files
committed
Fixed some non Python3 compliant code and addressed review comments.
1 parent 93969e2 commit dec3739

36 files changed

+265
-264
lines changed

build/ReleaseManager/tags_all.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ v3_4:
154154
- Increased testing (more than doubled unit tests coverage and testing more files
155155
w/ pylint)
156156
NOTE:
157-
- The type of the GLIDEIN_CPU attr is String (to accommodate the keywords auto, slot,
157+
- The type of the GLIDEIN_CPUS attr is String (to accommodate the keywords auto, slot,
158158
node). Documentation was reporting Int incorrectly. Make sure your configuration
159159
uses the correct type or you may get a reconfig/upgrade error.
160160
- If you use HTCondor 8.7.2 or bigger with the GlideinWMS Factory, you must install
@@ -452,7 +452,7 @@ v3_2_19:
452452
to multiple schedds on the Factory"
453453
- Clarified attribute types and fixed globbing behavior
454454
- RPM verification fails when config files are changed
455-
- 'GLIDEIN_CPU settings "node" and "slot" supported also in Frontend,
455+
- 'GLIDEIN_CPUS settings "node" and "slot" supported also in Frontend,
456456
457457
better documented and improved to compensate for PBS misconfiguration'
458458
- Fixed submission to AWS which uses key_pair as auth_method

factory/glideFactory.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ def _set_rlimit(soft_l=None, hard_l=None):
507507
the inherited limits from the parent process are used.
508508
509509
Note:
510-
It is possible to raise limits up to [hard_l, hard_l] but once lowered they cannot be raised.
510+
It is possible to raise limits up to [hard_l, hard_l], i.e. soft limit can be raised by a non-root user up
511+
to the current process hard limit, but once lowered they cannot be raised.
511512
It may be better to omit calling this function from subprocesses so that they inherit limits from the parent.
512513
513514
Args:

factory/glideFactoryConfig.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ConfigFile:
7171
Loads a file composed of
7272
NAME VAL
7373
lines and creates a dictionary where each key is assigned the value produced
74-
by applying the conversion function to the corresponding string. The default
74+
by applying the conversion function to the corresponding value string. The default
7575
conversion is repr, but a custom conversion function can be provided:
7676
self.data[NAME]=convert_function(VAL)
7777
It also defines:
@@ -90,7 +90,7 @@ def __init__(self, config_file, convert_function=repr):
9090
9191
Args:
9292
config_file (str): The path to the configuration file.
93-
convert_function (Callable, optional): Function to convert string values.
93+
convert_function (Callable, optional): Function to convert value strings.
9494
Defaults to repr.
9595
"""
9696
self.config_file = config_file
@@ -163,7 +163,7 @@ class EntryConfigFile(ConfigFile):
163163
Attributes:
164164
config_file (str): Name of file with entry directory (from parent ConfigFile)
165165
entry_name (str): Entry name
166-
config_file_short(str): Name of file (just the file name since the other had the directory)
166+
config_file_short (str): Name of file (just the file name since the other had the directory)
167167
"""
168168

169169
def __init__(self, entry_name, config_file, convert_function=repr):
@@ -188,7 +188,7 @@ class JoinConfigFile(ConfigFile):
188188
This class does not support saving changes to disk.
189189
190190
Attributes:
191-
config_file(str): Name of both files, with and without entry directory, with " AND " in the middle.
191+
config_file (str): Name of both files, with and without entry directory, with " AND " in the middle.
192192
It is not an actual file. (from parent ConfigFile, different value)
193193
data (dict): Will contain the joint items (initially the common one, then is updated using
194194
the content of `entry_obj.data`) (from parent ConfigFile, different value)
@@ -303,7 +303,7 @@ def get_pub_key_id(self):
303303
return self.pub_key_id[0:]
304304

305305
def extract_sym_key(self, enc_sym_key):
306-
"""Extract the symmetric key from an encrypted value (Fronted attribute).
306+
"""Extract the symmetric key from an encrypted value (Frontend attribute).
307307
308308
Args:
309309
enc_sym_key (str): Encrypted symmetric key as an ASCII string (AnyStrASCII).

factory/glideFactoryCredentials.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class SubmitCredentials:
4848
4949
Attributes:
5050
username (str): The username for submission.
51-
security_class: The security class for submission. (Seems redundant info)
51+
security_class: The security class for submission.
5252
id: The identifier used for tracking the submit credentials.
5353
cred_dir (str): The directory location of credentials.
5454
security_credentials (dict): Dictionary mapping credential types to file paths.
@@ -212,8 +212,8 @@ def process_global(classad, glidein_descript, frontend_descript):
212212
213213
Args:
214214
classad (dict): A dictionary representation of the classad.
215-
glidein_descript (glideFactoryConfig.GlideinDescript): The glidein description object.
216-
frontend_descript (glideFactoryConfig.FrontendDescript): The frontend description object.
215+
glidein_descript (glideFactoryConfig.GlideinDescript): Factory configuration's Glidein description object.
216+
frontend_descript (glideFactoryConfig.FrontendDescript): Factory configuration's Frontend description object.
217217
218218
Raises:
219219
CredentialError: If the factory has no public key or if any decryption error occurs.
@@ -295,7 +295,7 @@ def validate_frontend(classad, frontend_descript, pub_key_obj):
295295
296296
Args:
297297
classad (dict): A dictionary representation of the classad.
298-
frontend_descript (glideFactoryConfig.FrontendDescript): Object containing Frontend information.
298+
frontend_descript (glideFactoryConfig.FrontendDescript): Factory configuration's Frontend description object.
299299
pub_key_obj (object): The Factory public key object with encryption/decryption methods.
300300
301301
Returns:

factory/glideFactoryDowntimeLib.py

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: 2009 Fermi Research Alliance, LLC
22
# SPDX-License-Identifier: Apache-2.0
33

4-
"""This module implements the functions needed to handle the downtimes
4+
"""This module implements the functions needed to handle the downtimes.
55
"""
66

77
import fcntl
@@ -23,8 +23,8 @@ class DowntimeFile:
2323
Each non-comment line in the file must have at least two space-separated entries (start_time and end_time),
2424
expressed in Unix time (seconds since epoch). If end_time is "None", the downtime does not have
2525
a set expiration (i.e. it runs forever). Additional entries may be used to limit the scope
26-
(Entry, Frontend, Sec_Class names) and to add a comment. Missing values or, respectively "factory",
27-
"All", "All" mean that there are no scope restrictions.
26+
(Entry, Frontend, Sec_Class names) and to add a comment. Missing scope values or, respectively, the keywords
27+
"factory", "All", "All" mean that there are no scope restrictions.
2828
"""
2929

3030
def __init__(self, fname):
@@ -124,8 +124,8 @@ def start_downtime(
124124
):
125125
"""Start a downtime period with an indefinite end time.
126126
127-
If start_time is None, the current time is used. The default values for entry, frontend,
128-
and security_class are "All", meaning that there are no scope restrictions.
127+
If `start_time` is None, the current time is used. The default values for `entry`, `frontend`,
128+
and `security_class` are "All", meaning that there are no scope restrictions.
129129
130130
Args:
131131
start_time (int or None): The start time in seconds since the epoch.
@@ -140,7 +140,7 @@ def start_downtime(
140140
Defaults to True.
141141
142142
Returns:
143-
int: The result of addPeriod (typically 0).
143+
int: The result of `add_period` (typically 0).
144144
"""
145145
if start_time is None:
146146
start_time = int(time.time())
@@ -149,8 +149,8 @@ def start_downtime(
149149
def end_downtime(self, end_time=None, entry="All", frontend="All", security_class="All", comment=""):
150150
"""End an active downtime period.
151151
152-
If end_time is None, the current time is used. "All" (default) is a wildcard for entry,
153-
frontend, and security_class.
152+
If `end_time` is None, the current time is used. "All" (default) is a wildcard for `entry`,
153+
`frontend`, and `security_class`, meaning that there are no scope restrictions.
154154
155155
Args:
156156
end_time (int or None): The end time in seconds since the epoch.
@@ -329,9 +329,10 @@ def _print_downtime(fname, entry="Any", check_time=None):
329329
def _check_downtime(fname, entry="Any", frontend="Any", security_class="Any", check_time=None):
330330
"""Check if a downtime period is active at the specified time.
331331
332-
If check_time is None, the current time is used.
333-
entry, frontend, and security_class can be used to restrict the scope.
334-
"All" is used as a wildcard for entry, frontend, and security_class.
332+
If `check_time` is None, the current time is used.
333+
`entry`, `frontend`, and `security_class` can be used to restrict the scope.
334+
"All" is used as a wildcard for `entry`, `frontend`, and `security_class`,
335+
to avoid scope restrictions.
335336
336337
Args:
337338
fname (str or Path): The downtime file.
@@ -396,7 +397,7 @@ def _add_period(
396397
int: 0 upon successful addition.
397398
398399
Raises:
399-
FileNotFoundError: if there is no downtime file and create_if_empty is False
400+
FileNotFoundError: if there is no downtime file and create_if_empty is False.
400401
"""
401402
exists = os.path.isfile(fname)
402403
if (not exists) and (not create_if_empty):
@@ -523,8 +524,9 @@ def _purge_old_periods(fname, cut_time=None, raise_on_error=False):
523524
def _end_downtime(fname, end_time=None, entry="All", frontend="All", security_class="All", comment=""):
524525
"""End an active downtime period.
525526
526-
If end_time is None, the current time is used.
527-
"All" (default) is used as a wildcard for entry, frontend, and security_class.
527+
If `end_time` is None, the current time is used.
528+
"All" (default) is used as a wildcard for `entry`, `frontend`, and `security_class`,
529+
to avoid scope restrictions.
528530
529531
Args:
530532
fname (str or Path): The downtime file.

factory/glideFactoryEntry.py

+12-24
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ def loadContext(self):
175175
def getGlideinExpectedCores(self):
176176
"""Return the expected number of cores for each glidein.
177177
178-
This returns the value of the GLIDEIN_CPU attribute if > 0;
179-
otherwise, it returns the GLIDEIN_ESTIMATED_CPUS value when GLIDEIN_CPU <= 0
178+
This returns the value of the GLIDEIN_CPUS attribute if > 0;
179+
otherwise, it returns the GLIDEIN_ESTIMATED_CPUS value when GLIDEIN_CPUS <= 0
180180
or a string (auto/node/slot) or 1 if not set.
181181
Note that this number is used in provisioning and set in HTCondor. The actual
182-
number of cores used will depend on the RSL or HTCondor attributes and the Entry
182+
number of cores used will depend on the RSL or HTCondor attributes, on the Entry,
183183
and could also vary over time.
184184
185185
Returns:
@@ -235,7 +235,7 @@ def loadDowntimes(self):
235235
self.jobAttributes.data["GLIDEIN_Downtime_Comment"] = self.downtimes.downtime_comment
236236

237237
def isClientBlacklisted(self, client_sec_name):
238-
"""Check if a client (Frontend) is blacklisted. I.e. the whitelist is enable and the client is not in the list.
238+
"""Check if a client (Frontend) is blacklisted. I.e. the whitelist is enabled and the client is not in the list.
239239
240240
Args:
241241
client_sec_name (str): The security name of the client.
@@ -507,7 +507,7 @@ def writeClassadsToFile(self, downtime_flag, gf_filename, gfc_filename, append=T
507507
Advertising is done in a separate function.
508508
509509
Args:
510-
downtime_flag (bool): Downtime flag.
510+
downtime_flag (bool): Flag indicating whether the Factory is in downtime or not.
511511
gf_filename (str): Filename to write the glidefactory classads.
512512
gfc_filename (str): Filename to write the glidefactoryclient classads.
513513
append (bool, optional): If True, append to existing files (i.e Multi ClassAds file);
@@ -657,7 +657,7 @@ def advertise(self, downtime_flag):
657657
"""Advertise the glidefactory and glidefactoryclient classads.
658658
659659
Args:
660-
downtime_flag (bool): Downtime flag.
660+
downtime_flag (bool): Flag indicating whether the Factory is in downtime or not.
661661
"""
662662
self.loadContext()
663663

@@ -736,7 +736,7 @@ def getLogStatsCurrentStatsData(self):
736736
return self.getLogStatsData(self.gflFactoryConfig.log_stats.current_stats_data)
737737

738738
def getLogStatsData(self, stats_data):
739-
"""Retrieve normalized log statistics data, `stats_data(stats_data[frontend][user].data)`, for pickling.
739+
"""Retrieve normalized log statistics data, ``stats_data[frontend][user].data``, for pickling.
740740
741741
Args:
742742
stats_data (dict): Dictionary of statistics data keyed by Frontend and user.
@@ -769,7 +769,7 @@ def setLogStatsCurrentStatsData(self, new_data):
769769
self.setLogStatsData(self.gflFactoryConfig.log_stats.current_stats_data, new_data)
770770

771771
def setLogStatsData(self, stats_data, new_data):
772-
"""Set log statistics data, `stats_data(stats_data[frontend][user].data)`, from pickled information.
772+
"""Set log statistics data, ``stats_data[frontend][user].data``, from pickled information.
773773
774774
Args:
775775
stats_data (dict): The existing statistics data.
@@ -812,19 +812,6 @@ def getState(self):
812812
}
813813
return state
814814

815-
def setState_old(self, state):
816-
"""Load the post work state from pickled information.
817-
818-
Args:
819-
state (dict): The pickled state after work has been performed.
820-
"""
821-
self.gflFactoryConfig.client_stats = state.get("client_stats")
822-
self.gflFactoryConfig.qc_stats = state.get("qc_stats")
823-
self.gflFactoryConfig.rrd_stats = state.get("rrd_stats")
824-
self.gflFactoryConfig.client_internals = state.get("client_internals")
825-
self.glideinTotals = state.get("glidein_totals")
826-
self.gflFactoryConfig.log_stats = state["log_stats"]
827-
828815
def setState(self, state):
829816
"""Load the post work state from pickled information.
830817
@@ -867,7 +854,7 @@ def setState(self, state):
867854
# Debugging functions
868855
#####################
869856
def logLogStats(self, marker=""):
870-
"""Log detailed log statistics for debugging.
857+
"""Log detailed statistics for debugging.
871858
872859
Args:
873860
marker (str, optional): A marker string to prefix the debug logs. Defaults to an empty string.
@@ -893,7 +880,7 @@ def check_and_perform_work(factory_in_downtime, entry, work):
893880
894881
This function checks if work needs to be done for the entry and processes each work request
895882
using the v3 protocol. It updates credentials, checks downtimes and whitelisting, and submits work.
896-
It is called by a child process per entry
883+
It is called by a child process per entry.
897884
898885
Args:
899886
factory_in_downtime (bool): True if the factory is in downtime.
@@ -1771,7 +1758,8 @@ def update_entries_stats(factory_in_downtime, entry_list):
17711758
TODO: #22163, skip update when in downtime?
17721759
17731760
Note:
1774-
qc_stats cannot be updated because the frontend certificate information are missing
1761+
`qc_stats` (the client queue information) cannot be updated because the
1762+
Frontend certificate information are missing.
17751763
17761764
Args:
17771765
factory_in_downtime (bool): True if the factory is in downtime.

factory/glideFactoryEntryGroup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def find_and_perform_work(do_advertize, factory_in_downtime, glideinDescript, fr
243243
glideinDescript (dict): Factory glidein configuration values.
244244
frontendDescript (dict): Security mappings for Frontend identities, security classes, and usernames.
245245
group_name (str): Name of the group.
246-
my_entries (dict): Dictionary of entry objects (Entry) keyed by entry name.
246+
my_entries (dict): Dictionary of entry objects (`glideFactoryEntry.Entry`) keyed by entry name.
247247
248248
Returns:
249249
dict: Dictionary of work done, keyed by entry name.
@@ -613,7 +613,7 @@ def main(parent_pid, sleep_time, advertize_rate, startup_dir, entry_names, group
613613
startup_dir (str|Path): The "home" directory for the entry.
614614
entry_names (str): Colon-separated list of entry names to process.
615615
group_id (str): Group ID (normally a number, with the "group_" prefix it forms the group name).
616-
It can change between Factory reconfigurations
616+
It can change between Factory reconfigurations.
617617
"""
618618
# Assume name to be group_[0,1,2] etc. Only required to create log_dir
619619
# where tasks common to the group will be stored. There is no other

0 commit comments

Comments
 (0)