Skip to content

Commit

Permalink
Merge pull request #3750 from ggonzr/enhancement/mcm-rest-client
Browse files Browse the repository at this point in the history
Use the new version for the McM REST client
  • Loading branch information
bbilin authored Sep 12, 2024
2 parents 77104f4 + 9bab77e commit 15a2c2f
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions bin/utils/request_fragment_check.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/env python3
import os
import warnings
import sys
import re
import argparse
Expand All @@ -11,9 +12,6 @@
import json
import ast
from datetime import datetime
#
#sys.path.append('/afs/cern.ch/cms/PPD/PdmV/tools/McM-QA/')
#from rest import McM
from json import dumps

parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -56,8 +54,31 @@

# Use no-id as identification mode in order not to use a SSO cookie
if args.local is False:
sys.path.append('/afs/cern.ch/cms/PPD/PdmV/tools/McM-QA/')
from rest import McM
try:
from rest import McM
except ModuleNotFoundError as e:
old_version_afs = '/afs/cern.ch/cms/PPD/PdmV/tools/McM'
try:
# INFO: Temporarily load the old version to avoid crashes with non-updated user code.
sys.path.append(old_version_afs)
from rest import McM

version_msg = (
"An old version of the McM module has been loaded from: %s. "
"This is a temporal patch to avoid unforeseen import errors with user's code. "
"Install a recent version following the instructions available at "
"https://github.com/cms-PdmV/mcm_scripts for future executions."
) % (old_version_afs)
warnings.warn(version_msg, DeprecationWarning)

except ModuleNotFoundError as e:
import_msg = (
"Install this module in your execution environment "
"by following the instructions available at: "
"https://github.com/cms-PdmV/mcm_scripts"
)
raise ModuleNotFoundError(import_msg) from e

mcm = McM(id=None, dev=args.dev, debug=args.debug)
mcm_link = mcm.server

Expand All @@ -78,15 +99,6 @@ def get_request(prepid):
result = result.get('results', {})
return result

#def get_request(prepid):
# result = mcm._McM__get('public/restapi/requests/get/%s' % (prepid))
# if not result:
# return {}
#
# result = result.get('results', {})
# return result


def get_range_of_requests(query):
result = mcm._McM__put('public/restapi/requests/listwithfile', data={'contents': query})
if not result:
Expand Down

0 comments on commit 15a2c2f

Please sign in to comment.