From 6fb044d543e87d3dfcd166c3755e02aec53ad99a Mon Sep 17 00:00:00 2001 From: Jonas Bardino Date: Mon, 13 Oct 2025 12:36:21 +0200 Subject: [PATCH 1/5] WiP to address a few old lint errors triggered by PR #359 but caused elsewhere. --- mig/shared/functionality/autocreate.py | 1 + mig/shared/mrslparser.py | 1 + 2 files changed, 2 insertions(+) diff --git a/mig/shared/functionality/autocreate.py b/mig/shared/functionality/autocreate.py index 305691540..6988919d6 100644 --- a/mig/shared/functionality/autocreate.py +++ b/mig/shared/functionality/autocreate.py @@ -828,3 +828,4 @@ def main(client_id, user_arguments_dict, environ=None): Please contact the %(short_title)s support (%(support_email)s) if you think it should be enabled.""" % fill_helper}) return (output_objects, returnvalues.ERROR) + diff --git a/mig/shared/mrslparser.py b/mig/shared/mrslparser.py index 9ca2c6b29..db276eabc 100644 --- a/mig/shared/mrslparser.py +++ b/mig/shared/mrslparser.py @@ -396,3 +396,4 @@ def parse( # phew, we made it. Everything ok return (True, '') + From f7628ee276da199cd9742498d9619c2e7ddda292 Mon Sep 17 00:00:00 2001 From: Jonas Bardino Date: Mon, 13 Oct 2025 12:43:11 +0200 Subject: [PATCH 2/5] Fix broken lazy list init as pointed out by pylint: `E1111: Assigning result of a function call, where the function has no return (assignment-from-no-return)` --- mig/shared/mrslparser.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mig/shared/mrslparser.py b/mig/shared/mrslparser.py index db276eabc..e7d26f08e 100644 --- a/mig/shared/mrslparser.py +++ b/mig/shared/mrslparser.py @@ -4,7 +4,7 @@ # --- BEGIN_HEADER --- # # mrslparser - Parse mRSL job descriptions -# Copyright (C) 2003-2021 The MiG Project lead by Brian Vinter +# Copyright (C) 2003-2025 The MiG Project by the Science HPC Center at UCPH # # This file is part of MiG. # @@ -20,7 +20,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. # # -- END_HEADER --- # @@ -136,7 +137,7 @@ def parse( if not status: return (False, 'Parse failed (typecheck) %s' % msg) - #logger.debug('check_types updated job dict to: %s' % external_dict) + # logger.debug('check_types updated job dict to: %s' % external_dict) global_dict = {} @@ -375,9 +376,8 @@ def parse( else: before_runt_dict = resource_config['RUNTVERIFICATION'] if re_name not in before_runt_dict: - before_runt_dict[re_name] = [].append(dict_entry) - else: - before_runt_dict[re_name].append(dict_entry) + before_runt_dict[re_name] = [] + before_runt_dict[re_name].append(dict_entry) # save dict with added entry @@ -396,4 +396,3 @@ def parse( # phew, we made it. Everything ok return (True, '') - From e27629f6be2f184eddc8a6a5c1f9c1e06efaae3c Mon Sep 17 00:00:00 2001 From: Jonas Bardino Date: Mon, 13 Oct 2025 12:49:42 +0200 Subject: [PATCH 3/5] Try to address a number of pylint warnings like `E0606: Possibly using variable 'email' before assignment (possibly-used-before-assignment)` by bailing out with ValueError if unexpected `auth_type` was hit. --- mig/shared/functionality/autocreate.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mig/shared/functionality/autocreate.py b/mig/shared/functionality/autocreate.py index 6988919d6..ef46c99dd 100644 --- a/mig/shared/functionality/autocreate.py +++ b/mig/shared/functionality/autocreate.py @@ -4,7 +4,7 @@ # --- BEGIN_HEADER --- # # autocreate - auto create user from signed certificate or openid login -# Copyright (C) 2003-2024 The MiG Project lead by Brian Vinter +# Copyright (C) 2003-2025 The MiG Project lead by Brian Vinter # # This file is part of MiG. # @@ -20,7 +20,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. # # -- END_HEADER --- # @@ -395,6 +396,11 @@ def main(client_id, user_arguments_dict, environ=None): state = accepted['state'][-1].strip() org = accepted['org'][-1].strip() org_unit = '' + + # NOTE: no tokens involved here + token_issuer = '' + token_audience = '' + # NOTE: leave role and association alone here role = '' association = '' @@ -429,6 +435,10 @@ def main(client_id, user_arguments_dict, environ=None): org_unit = accepted['openid.sreg.ou'][-1].strip() \ or accepted['openid.sreg.organizational_unit'][-1].strip() + # NOTE: no tokens involved here + token_issuer = '' + token_audience = '' + # We may receive multiple roles and associations merged = accepted['openid.sreg.role'] + accepted['openid.sreg.roles'] @@ -469,6 +479,8 @@ def main(client_id, user_arguments_dict, environ=None): # translate to individual args instead in that case. E.g. as in # 'john@doe.org,jd@doe.org' -> ['john@doe.org', 'jd@doe.org'] email = split_comma_concat(accepted['oidc.claim.email'])[-1].strip() + else: + raise ValueError("Unsupported auth type: %r" % auth_type) # We may encounter results without an email, fall back to try plain IDs then if not email: @@ -828,4 +840,3 @@ def main(client_id, user_arguments_dict, environ=None): Please contact the %(short_title)s support (%(support_email)s) if you think it should be enabled.""" % fill_helper}) return (output_objects, returnvalues.ERROR) - From 5265d78bc3e08a1bd6f5eb5b9cd796cd4eaff7ba Mon Sep 17 00:00:00 2001 From: Jonas Bardino Date: Mon, 13 Oct 2025 12:56:08 +0200 Subject: [PATCH 4/5] Fix a couple of pylint warnings like `E0606: Possibly using variable 'last_res' before assignment (possibly-used-before-assignment)` by moving init up above conditional. --- mig/server/grid_script.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mig/server/grid_script.py b/mig/server/grid_script.py index b48078f00..739d0fdb7 100755 --- a/mig/server/grid_script.py +++ b/mig/server/grid_script.py @@ -4,7 +4,7 @@ # --- BEGIN_HEADER --- # # grid_script - the core job handling daemon on a MiG server -# Copyright (C) 2003-2023 The MiG Project lead by Brian Vinter +# Copyright (C) 2003-2025 The MiG Project by the Science HPC Center at UCPH # # This file is part of MiG. # @@ -20,7 +20,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. # # -- END_HEADER --- # @@ -693,11 +694,9 @@ def graceful_shutdown(): exe_job = \ executing_queue.get_job_by_id(job_dict['JOB_ID' ]) + # Ignore missing fields + (last_res, last_exe) = ('', '') if exe_job: - - # Ignore missing fields - - (last_res, last_exe) = ('', '') if 'UNIQUE_RESOURCE_NAME' in exe_job: last_res = exe_job['UNIQUE_RESOURCE_NAME'] if 'EXE' in exe_job: @@ -799,7 +798,8 @@ def graceful_shutdown(): vgrids_in_prioritized_order = [] - list_indices = [(last_vgrid + i) % len(exe_vgrids) for i in range(len(exe_vgrids))] + list_indices = [(last_vgrid + i) % len(exe_vgrids) + for i in range(len(exe_vgrids))] for index in list_indices: # replace "" with default_vgrid From c5934066c55d3ca2bf4b0424911934265fc2dbb6 Mon Sep 17 00:00:00 2001 From: Jonas Bardino Date: Mon, 13 Oct 2025 13:14:42 +0200 Subject: [PATCH 5/5] Minor comment update in copyright note. --- mig/shared/functionality/autocreate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mig/shared/functionality/autocreate.py b/mig/shared/functionality/autocreate.py index ef46c99dd..3e9e4504a 100644 --- a/mig/shared/functionality/autocreate.py +++ b/mig/shared/functionality/autocreate.py @@ -4,7 +4,7 @@ # --- BEGIN_HEADER --- # # autocreate - auto create user from signed certificate or openid login -# Copyright (C) 2003-2025 The MiG Project lead by Brian Vinter +# Copyright (C) 2003-2025 The MiG Project by the Science HPC Center at UCPH # # This file is part of MiG. #