locked
Would it be possible to access the system-wide job and task ids immediately after creation? RRS feed

  • Question

  • IWBNI after creating a job/task that it was possible to access the system-wide ids immediately.

     

    Obviously the actual submitted ids (ISchedulerJob.id/ISchedulerTask.TaskId.JobTaskId) would differ.

     

    Sadly ISchedulerJob is of course currently an int and would obviously be a significant and code-breaking change, however, TaskId/ITaskId could implement the TaskId.SystemId mentioned in the docs (at least not in my version of the assemblies).

     

    This would, for example, allow me to group temp files (e.g. stdout/stderr output files) based on this job/task.

     

    MTIA

     

    Andy

    Monday, April 14, 2008 12:47 PM

Answers

  • Andy,

     

    When the ISchedulerTask or ISchedulerJob objects are first created, they are local to the client computer until either IScheduler.AddJob() or IScheduler.SubmitJob() are called.

     

    After they have been created on the server, they will have the id's set on them.

     

    The code below should help:

     

    private void Foo1()

    {

    Scheduler scheduler = new Scheduler();

    scheduler.Connect("localhost");

     

    ISchedulerJob job = scheduler.CreateJob();

     

     

    for (int i = 0; i < 10; i++)

    {

    ISchedulerTask task = job.CreateTask();

    job.AddTask(task);

    }

     

    scheduler.AddJob(job);

     

    foreach (ISchedulerTask taskNew in job.GetTaskList(null, null))

    {

    taskNew.StdInFilePath = @"c:\temp\job" + job.Id + @"\" + taskNew.TaskId.JobTaskId + @".txt";

    taskNew.Commit();

    }

     

    scheduler.SubmitJob(job, "username", "password");

    }

     

    When scheduler.AddJob() is called, the API will create a new job within the Store, then it will create all the tasks that were added.  At this time, the API will refresh all the properties on the objects (including the id's for the objects).

     

    Hope this helps,

    -Greg

     

    Monday, April 14, 2008 10:07 PM

All replies

  •  

    Andy,

    I'll bring your API request up with Dev.

     

    In the meantime . . . we have many customers who've expressed a desire to create per job/task files and directories.  We generally recommend using the auto-generated CCP_JOBID and CCP_TASKID environment variables.

     

    For example, doing:

    Code Snippet

    C:>job submit /stdout:\\server\share\Job%CCP_JOBID%.Task%CCP_TASKID%.out echo test

     

    That will create a file called Job15.Task2.out on your fileshare.

     

    Thanks,
    Josh

    Monday, April 14, 2008 9:23 PM
    Moderator
  • Andy,

     

    When the ISchedulerTask or ISchedulerJob objects are first created, they are local to the client computer until either IScheduler.AddJob() or IScheduler.SubmitJob() are called.

     

    After they have been created on the server, they will have the id's set on them.

     

    The code below should help:

     

    private void Foo1()

    {

    Scheduler scheduler = new Scheduler();

    scheduler.Connect("localhost");

     

    ISchedulerJob job = scheduler.CreateJob();

     

     

    for (int i = 0; i < 10; i++)

    {

    ISchedulerTask task = job.CreateTask();

    job.AddTask(task);

    }

     

    scheduler.AddJob(job);

     

    foreach (ISchedulerTask taskNew in job.GetTaskList(null, null))

    {

    taskNew.StdInFilePath = @"c:\temp\job" + job.Id + @"\" + taskNew.TaskId.JobTaskId + @".txt";

    taskNew.Commit();

    }

     

    scheduler.SubmitJob(job, "username", "password");

    }

     

    When scheduler.AddJob() is called, the API will create a new job within the Store, then it will create all the tasks that were added.  At this time, the API will refresh all the properties on the objects (including the id's for the objects).

     

    Hope this helps,

    -Greg

     

    Monday, April 14, 2008 10:07 PM
  • Josh,

     

    your example:

     

     Barndawgie wrote:

     

    Code Snippet

    C:>job submit /stdout:\\server\share\Job%CCP_JOBID%.Task%CCP_TASKID%.out echo test

     

     

    will surely expand CPP_JOBID and CPP_TASKID based on the current environment, not on the submitted job's id.

     

    Andy

    Tuesday, April 15, 2008 3:21 PM
  • Greg,

     

    thanks for that I'd forgotten the AddJob.

     

    Just what I needed, a combination of:

     

      ISchedulerJob.AddTask(ISchedulerTask);

      IScheduler.AddJob(ISchedulerJob); // add, but don't submit the job

      ISchedulerTask.Refresh();  // to update the task from the scheduler

      ISchedulerTask changes

      ISchedulerTask.Commit(); // commit the changes made above

     

    Thanks again,

     

    Andy

    Tuesday, April 15, 2008 3:51 PM
  •  

    The variables will actually be expanded at the compute node, since they don't exist on the client.

     

    Thanks,

    Josh

    Tuesday, April 15, 2008 4:48 PM
    Moderator
  •  Barndawgie wrote:

     

    The variables will actually be expanded at the compute node, since they don't exist on the client.

     

    Thanks,

    Josh

     

    Cute ... thanks.

     

    I notice we can include "*" in the filename for parametric tasks and now I find that environment variables are expanded on the compute node, are there any other substitutions I should be aware of?

     

    Thanks

    Andy

    Tuesday, April 15, 2008 4:59 PM
  •  

    Nope . . . that should be it

    Wednesday, April 16, 2008 6:45 AM
    Moderator