PipelineFX Forum

Qube! => Developer Customization => Topic started by: lwakeland on March 11, 2008, 07:42:20 PM

Title: QbModifyCommand
Post by: lwakeland on March 11, 2008, 07:42:20 PM
I need to modify the priority of jobs using the c++ api.
I assume I need to use the fields and the modify command 
to modify this but I am unclear as to how to do this

Thanks

Lewis
Title: Re: QbModifyCommand
Post by: lwakeland on March 12, 2008, 12:13:48 AM
To be more specific,
In python it would be qb.modify({'priority':123}, 250)
in C++ it would be qbmodify( ???????, jobs);
What is ?????? (in particular, for a priority change.
Title: Re: QbModifyCommand
Post by: shinya on March 12, 2008, 12:51:11 AM
Hi Lewis

Here's a sample program that would set a given job's priority:
----
Code: [Select]
#include "QbApi.h"

int main(int argc, char *argv[])
{
        if(argc < 3) {
                cerr << "ERROR: insufficient args\n";
                cerr << "Usage: " << argv[0] << " <jobID> <newPriority>\n";
                exit(1);
        }

        QbModifyCommand cmd;
        cmd.jobids().push(new QbJobId(atoi(argv[1])));
        cmd.fields().push(new QbField("priority"));

        QbJob job;
        job.priority(atoi(argv[2]));
        cmd.job(job);

        QbJobIdList jobs;
        QB_BOOL result = qbmodify(cmd, jobs);
        if(!result) {
                cerr << "ERROR: couldn't send command to supervisor." << endl;
                exit(1);
        }

        cout << "modified jobs: ";
        for (int i = 0; i < jobs.length(); i++) {
                cout << jobs.get(i)->id() << " ";
        }
        cout << endl;

        return 0;
}
Title: Re: QbModifyCommand
Post by: ujj on December 23, 2010, 07:18:34 PM
Hello. 

I have a question regarding qb.modify() as well.  I am trying to use the "notes" field to denote more granular app specific status.  To do that I am attempting to modify the notes field as my job proceeds.

This is the method I am using, passing it with the ip of the supervisor and a dictionary like {'notes' : 'some_foo_value'}

def update_qube_job_properties(qube_supervisor, modify_param_dict):
    qube_job_id = os.environ['QBJOBID']
    try:
        qb.setsupervisor(qube_supervisor)
        qb.modify(modify_param_dict, int(qube_job_id))
        qube_job_info = qb.jobinfo(id=int(qube_job_id))[0]
    except:
        logging.debug(sys.exc_info()[0])
    return qube_job_info


qb.modify is returning a null list as a result, any insight?

Thank you.