Skip to content

Commit

Permalink
Use the new version for the McM REST client
Browse files Browse the repository at this point in the history
1. Remove all the instructions that load this module from AFS.
2. Raise a detailed exception explaining how to install the new version
   if the module is not available.
3. Update instructions that used `mangled` methods available in the McM
   class to avoid `DeprecationWarning` messages
  • Loading branch information
ggonzr committed Aug 20, 2024
1 parent 45b4790 commit a944f5b
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions bin/utils/request_fragment_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,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,14 +53,23 @@

# 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:
import_msg = (
"Unable to import the McM module. "
"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

def get_request(prepid):
if args.local is False:
result = mcm._McM__get('public/restapi/requests/get/%s' % (prepid))
result = mcm._get('public/restapi/requests/get/%s' % (prepid))
if args.download_json is True:
with open("request_"+prepid+".json",'w') as f:
json.dump(result,f)
Expand All @@ -78,17 +84,8 @@ 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})
result = mcm._put('public/restapi/requests/listwithfile', data={'contents': query})
if not result:
return {}

Expand All @@ -97,15 +94,15 @@ def get_range_of_requests(query):


def get_ticket(prepid):
result = mcm._McM__get('public/restapi/mccms/get/%s' % (prepid))
result = mcm._get('public/restapi/mccms/get/%s' % (prepid))
if not result:
return {}

result = result.get('results', {})
return result

def get_requests_from_datasetname(dn):
raw_result = mcm._McM__get(
raw_result = mcm._get(
"public/restapi/requests/from_dataset_name/%s" % (dn)
)
if not raw_result:
Expand Down

0 comments on commit a944f5b

Please sign in to comment.