コード例 #1
0
def main():
    url='cmsweb.cern.ch'
    
    #Create option parser
    usage = "\n       python %prog [-f FILE_NAME | WORKFLOW_NAME ...]\n"
    parser = OptionParser(usage=usage)
    parser.add_option('-f', '--file', help='Text file with a list of workflows', dest='file')
    parser.add_option('-i', '--invalidate', action='store_true', default=False,
                      help='Also invalidate output datasets on DBS', dest='invalidate')
    (options, args) = parser.parse_args()
    
    if options.file:
        wfs = [l.strip() for l in open(options.file) if l.strip()]
    elif args:
        wfs = args
    else:
        parser.error("Provide the workflow of a file of workflows")
        sys.exit(1)
    
    for wf in wfs:
        print "Rejecting workflow: " + wf
        reqMgrClient.rejectWorkflow(url, wf)
        print "Rejected"
        if options.invalidate:
            print "Invalidating datasets"
            datasets = reqMgrClient.outputdatasetsWorkflow(url, wf)
            for ds in datasets:
                print ds
                dbs3.setDatasetStatus(ds, 'INVALID', files=True)
コード例 #2
0
def main():
    """
    Read the text file, for each workflow try:
    First abort it, then clone it.
    """
    usage = "\n       python %prog [options] [WORKFLOW_NAME] [USER GROUP]\n"\
            "WORKFLOW_NAME: if the list file is provided this should be empty\n"\
            "USER: the user for creating the clone, if empty it will\n"\
            "      use the OS user running the script\n"\
            "GROUP: the group for creating the clone, if empty it will\n"\
            "      use 'DATAOPS' by default"

    parser = OptionParser(usage=usage)
    parser.add_option('-f', '--file', help='Text file of workflows to Abort and Clone', dest='file')
    (options, args) = parser.parse_args()
    
    # Check the arguments, get info from them
    if options.file:
        wfs = [l.strip() for l in open(options.file) if l.strip()]
        if len(args) == 2:
            user = args[0]
            group = args[1]
        elif len(args) == 0:
            #get os username by default
            uinfo = pwd.getpwuid(os.getuid())
            user = uinfo.pw_name
            #group by default DATAOPS
            group = 'DATAOPS'
    else:
        if len(args) == 3:
            user = args[1]
            group = args[2]
        elif len(args) == 1:
            #get os username by default
            uinfo = pwd.getpwuid(os.getuid())
            user = uinfo.pw_name
            #group by default DATAOPS
            group = 'DATAOPS'
        else:
            parser.error("Provide the workflow of a file of workflows")
            sys.exit(1)
        #name of workflow
        wfs = [args[0]]

    for wf in wfs:
        #abort workflow
        print "Aborting workflow: " + wf
        reqMgrClient.abortWorkflow(url, wf)
        #invalidates datasets
        print "Invalidating datasets"
        datasets = reqMgrClient.outputdatasetsWorkflow(url, wf)
        for ds in datasets:
            print ds
            dbs3.setDatasetStatus(ds, 'INVALID', files=True)

        #clone workflow
        clone = resubmit.cloneWorkflow(wf, user, group)
    sys.exit(0);
コード例 #3
0
def main():
    """
    Read the text file, for each workflow try:
    First abort it, then clone it.
    """
    usage = "\n       python %prog [options] [WORKFLOW_NAME] [USER GROUP]\n"\
            "WORKFLOW_NAME: if the list file is provided this should be empty\n"\
            "USER: the user for creating the clone, if empty it will\n"\
            "      use the OS user running the script\n"\
            "GROUP: the group for creating the clone, if empty it will\n"\
            "      use 'DATAOPS' by default"

    parser = OptionParser(usage=usage)
    parser.add_option('-f', '--file', help='Text file of workflows to Reject and Clone', dest='file')
    (options, args) = parser.parse_args()
    
    # Check the arguments, get info from them
    if options.file:
        wfs = [l.strip() for l in open(options.file) if l.strip()]
        if len(args) == 2:
            user = args[0]
            group = args[1]
        elif len(args) == 0:
            #get os username by default
            uinfo = pwd.getpwuid(os.getuid())
            user = uinfo.pw_name
            #group by default DATAOPS
            group = 'DATAOPS'
    else:
        if len(args) == 3:
            user = args[1]
            group = args[2]
        elif len(args) == 1:
            #get os username by default
            uinfo = pwd.getpwuid(os.getuid())
            user = uinfo.pw_name
            #group by default DATAOPS
            group = 'DATAOPS'
        else:
            parser.error("Provide the workflow of a file of workflows")
            sys.exit(1)
        #name of workflow
        wfs = [args[0]]

    for wf in wfs:
        #abort workflow
        print "Rejecting workflow: " + wf
        reqMgrClient.rejectWorkflow(url, wf)
        #invalidates datasets
        print "Invalidating datasets"
        datasets = reqMgrClient.outputdatasetsWorkflow(url, wf)
        for ds in datasets:
            print ds
            dbs3.setDatasetStatus(ds, 'INVALID', files=True)

        #clone workflow
        clone = resubmit.cloneWorkflow(wf, user, group)
    sys.exit(0);
コード例 #4
0
ファイル: reject.py プロジェクト: amaltaro/WmAgentScripts
def main():
    usage = "\n       python %prog [options] [WORKFLOW_NAME]\n" \
            "WORKFLOW_NAME: if the list file is provided this should be empty\n"

    parser = OptionParser(usage=usage)
    parser.add_option('-f', '--file', help='Text file of workflows to Reject and Clone', dest='file')
    parser.add_option('-c', '--clone', help='Are the workflows going to be cloned? The default value is False',action="store_true", dest='clone', default=False)
    parser.add_option('-i', '--invalidate', help='Invalidate datasets? The default value is False',action="store_true", dest='invalidate', default=False)
    parser.add_option("-u", "--user", dest="user",help="The user for creating the clone, if empty it will use the OS user running the script")
    parser.add_option("-g", "--group", dest="group", default='DATAOPS',help="The group for creating the clone, if empty it will, use 'DATAOPS' by default")
    (options, args) = parser.parse_args()

    # Check the arguments, get info from them
    if options.file:
        try:
            workflows = [l.strip() for l in open(options.file) if l.strip()]
        except:
            parser.error("Provide a valid file of workflows")
            sys.exit(1)
    elif len(args) >0:
        # name of workflow
        workflows = [args[0]]
    else:
        parser.error("Provide the workflow of a file of workflows")
        sys.exit(1)

    if not options.user:
        # get os username by default
        uinfo = pwd.getpwuid(os.getuid())
        user = uinfo.pw_name
    else:
        user = options.user

    for workflow in workflows:
        try:
            workflowInfo = reqMgrClient.Workflow(workflow)
        except:
            print("The workflow name: "+ workflow+" is  not valid.")
            continue
        # invalidates workflow
        print("Invalidating the workflow: "+ workflow)
        reqMgrClient.invalidateWorkflow(url,workflow,workflowInfo.status)

        # invalidates datasets
        if options.invalidate:
            print("Invalidating datasets")
            datasets = reqMgrClient.outputdatasetsWorkflow(url, workflow)
            for dataset in datasets:
                print(dataset)
                dbs3.setDatasetStatus(dataset, 'INVALID', files=True)

        # clones workflow
        if options.clone:
            print("Cloning workflow: "+ workflow)
            cloned = resubmit.cloneWorkflow(workflow, user, options.group)
    sys.exit(0);
コード例 #5
0
def main():
    url = 'cmsweb.cern.ch'

    #Create option parser
    usage = "\n       python %prog [-f FILE_NAME | WORKFLOW_NAME ...]\n"
    parser = OptionParser(usage=usage)
    parser.add_option('-f',
                      '--file',
                      help='Text file with a list of workflows',
                      dest='file')
    parser.add_option('-i',
                      '--invalidate',
                      action='store_true',
                      default=False,
                      help='Also invalidate output datasets on DBS',
                      dest='invalidate')
    (options, args) = parser.parse_args()

    if options.file:
        wfs = [l.strip() for l in open(options.file) if l.strip()]
    elif args:
        wfs = args
    else:
        parser.error("Provide the workflow of a file of workflows")
        sys.exit(1)

    for wf in wfs:
        print "Aborting workflow: " + wf
        reqMgrClient.abortWorkflow(url, wf)
        print "Aborted"

        if options.invalidate:
            print "Invalidating datasets"
            datasets = reqMgrClient.outputdatasetsWorkflow(url, wf)
            for ds in datasets:
                print ds
                dbs3.setDatasetStatus(ds, 'INVALID', files=True)

    sys.exit(0)
コード例 #6
0
def main():
    usage = "\n       python %prog [options] [WORKFLOW_NAME]\n" \
            "WORKFLOW_NAME: if the list file is provided this should be empty\n"

    parser = OptionParser(usage=usage)
    parser.add_option('-f',
                      '--file',
                      help='Text file of workflows to Reject and Clone',
                      dest='file')
    parser.add_option(
        '-c',
        '--clone',
        help='Are the workflows going to be cloned? The default value is False',
        action="store_true",
        dest='clone',
        default=False)
    parser.add_option('-i',
                      '--invalidate',
                      help='Invalidate datasets? The default value is False',
                      action="store_true",
                      dest='invalidate',
                      default=False)
    parser.add_option(
        "-u",
        "--user",
        dest="user",
        help=
        "The user for creating the clone, if empty it will use the OS user running the script"
    )
    parser.add_option(
        "-g",
        "--group",
        dest="group",
        default='DATAOPS',
        help=
        "The group for creating the clone, if empty it will, use 'DATAOPS' by default"
    )
    parser.add_option(
        "-m",
        "--memory",
        dest="memory",
        help=
        "Set max memory for the clone. At assignment, this will be used to calculate maxRSS = memory*1024"
    )

    (options, args) = parser.parse_args()

    # Check the arguments, get info from them
    if options.file:
        try:
            workflows = [l.strip() for l in open(options.file) if l.strip()]
        except:
            parser.error("Provide a valid file of workflows")
            sys.exit(1)
    elif len(args) > 0:
        # name of workflow
        workflows = [args[0]]
    else:
        parser.error("Provide the workflow of a file of workflows")
        sys.exit(1)

    if not options.user:
        # get os username by default
        uinfo = pwd.getpwuid(os.getuid())
        user = uinfo.pw_name
    else:
        user = options.user

    for workflow in workflows:
        try:
            workflowInfo = reqMgrClient.Workflow(workflow)
        except:
            print("The workflow name: " + workflow + " is  not valid.")
            continue
        # invalidates workflow
        print("Invalidating the workflow: " + workflow)
        reqMgrClient.invalidateWorkflow(url, workflow, workflowInfo.status)

        # invalidates datasets
        if options.invalidate:
            print("Invalidating datasets")
            datasets = reqMgrClient.outputdatasetsWorkflow(url, workflow)
            for dataset in datasets:
                print(dataset)
                dbs3.setDatasetStatus(dataset, 'INVALID', files=True)

        # clones workflow
        if options.clone:
            print("Cloning workflow: " + workflow)
            if options.memory:
                mem = options.memory
            else:
                mem = workflowInfo.info["Memory"]
            cloned = resubmit.cloneWorkflow(workflow,
                                            user,
                                            options.group,
                                            memory=mem)
    sys.exit(0)
コード例 #7
0
ファイル: reject.py プロジェクト: CMSCompOps/WmAgentScripts
def main():
    usage = (
        "\n       python %prog [options] [WORKFLOW_NAME]\n"
        "WORKFLOW_NAME: if the list file is provided this should be empty\n"
    )

    parser = OptionParser(usage=usage)
    parser.add_option("-f", "--file", help="Text file of workflows to Reject and Clone", dest="file")
    parser.add_option(
        "-c",
        "--clone",
        help="Are the workflows going to be cloned? The default value is False",
        action="store_true",
        dest="clone",
        default=False,
    )
    parser.add_option(
        "-i",
        "--invalidate",
        help="Invalidate datasets? The default value is False",
        action="store_true",
        dest="invalidate",
        default=False,
    )
    parser.add_option(
        "-u",
        "--user",
        dest="user",
        help="The user for creating the clone, if empty it will use the OS user running the script",
    )
    parser.add_option(
        "-g",
        "--group",
        dest="group",
        default="DATAOPS",
        help="The group for creating the clone, if empty it will, use 'DATAOPS' by default",
    )
    parser.add_option(
        "-m",
        "--memory",
        dest="memory",
        help="Set max memory for the clone. At assignment, this will be used to calculate maxRSS = memory*1024",
    )

    (options, args) = parser.parse_args()

    # Check the arguments, get info from them
    if options.file:
        try:
            workflows = [l.strip() for l in open(options.file) if l.strip()]
        except:
            parser.error("Provide a valid file of workflows")
            sys.exit(1)
    elif len(args) > 0:
        # name of workflow
        workflows = [args[0]]
    else:
        parser.error("Provide the workflow of a file of workflows")
        sys.exit(1)

    if not options.user:
        # get os username by default
        uinfo = pwd.getpwuid(os.getuid())
        user = uinfo.pw_name
    else:
        user = options.user

    for workflow in workflows:
        try:
            workflowInfo = reqMgrClient.Workflow(workflow)
        except:
            print("The workflow name: " + workflow + " is  not valid.")
            continue
        # invalidates workflow
        print("Invalidating the workflow: " + workflow)
        reqMgrClient.invalidateWorkflow(url, workflow, workflowInfo.status)

        # invalidates datasets
        if options.invalidate:
            print("Invalidating datasets")
            datasets = reqMgrClient.outputdatasetsWorkflow(url, workflow)
            for dataset in datasets:
                print(dataset)
                dbs3.setDatasetStatus(dataset, "INVALID", files=True)

        # clones workflow
        if options.clone:
            print("Cloning workflow: " + workflow)
            if options.memory:
                mem = float(options.memory)
            else:
                mem = workflowInfo.info["Memory"]
            cloned = resubmit.cloneWorkflow(workflow, user, options.group, memory=mem)
    sys.exit(0)