# Simple Question: Execute python code on a LSF submit host

**URL:** <https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560>\
**Category:** Get Help\
**Tags:** question\
**Created:** [June 12, 2024, 2:57pm UTC](https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560 "2024-06-12T14:57:39Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![dweise1776](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/dweise1776/32/1295_2.png) [@dweise1776](https://discourse.openondemand.org/u/dweise1776)\
**Post date:** [June 13, 2024, 5:43pm UTC](https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560/21 "2024-06-13T17:43:30Z")

</div>

Hi,  
So after some digging and a few batch submissions and combing through these forums, this is the fix that needs to be done:  
As above Ondemand sets correctly.  
“Script location” = SLURM\_SUBMIT\_DIR = PWD  
So for LSF we just need Ondemand to set almost the same thing:  
“Script Location” = LS\_SUBCWD = PWD.

How can we get this done?  
–David

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [June 13, 2024, 5:49pm UTC](https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560/22 "2024-06-13T17:49:29Z")

</div>

`OOD_DATAROOT` could be a long term solution, but even then, if you set it to $HOME, you’d still get directories like `$HOME/myjobs/projects/34`.

Are you still `ssh`ing into another machine to submit jobs? If you are, that’s the cause of not finding the file. Because you’ve sshed into another machine, you’re in your $HOME when you submit the job. And since your in your $HOME when you submit the job, that’s where the $CWD of the job is.

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [June 13, 2024, 5:50pm UTC](https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560/23 "2024-06-13T17:50:13Z")

</div>

Sorry I appear to have had that message queued up all morning.

But yes, SLURM\_SUBMIT\_DIR = PWD because I am not sshing into another machine and thus changing my PWD.

---

<div class="post-metadata">

**Author:** ![dweise1776](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/dweise1776/32/1295_2.png) [@dweise1776](https://discourse.openondemand.org/u/dweise1776)\
**Post date:** [June 13, 2024, 6:01pm UTC](https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560/24 "2024-06-13T18:01:46Z")

</div>

Hi,  
I did change OOD\_DATAROOT and it made the path shorter. I put /home/$USER/ondemand in the files:  
/etc/ood/config/apps/myjobs/env  
/etc/ood/config/apps/dashboard/env  
But then open ondemand appended “projects/default/2”  
So to recap:  
If I ssh to a submit host OR I use the ondemand server as a submit host it doesn’t work. Because ondemand never sets “Script Location” = LS\_SUBCWD = PWD.  
It will always say “your python/R/etc isn’t found”

And just to be clear, the modules isn’t a problem if I “copy environment”.  
–David

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [June 13, 2024, 6:16pm UTC](https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560/25 "2024-06-13T18:16:57Z")

</div>

> [@dweise1776](#):
>
> If I ssh to a submit host OR I use the ondemand server as a submit host it doesn’t work

This is very confusing to me, because I took a look and confirmed that we change directories into the correct directory when submitting the job. So when we issue `bsub` we’re in the correct directory.

So if you’re indeed using the ondemand server as a submit host, it really should be setting the correct PWD.

In Slurm, I can query the database and get additional information about the job using `sacct`. I just ran this job and checked it’s `WorkDir` and it’s correct.

```auto
[4(master)] pwd
/users/PZS0714/johrstrom/ondemand/src/apps/myjobs/data/projects/default/4
[4(master)] ls 
main_job.sh slurm-31225227.out
[4(master)] sacct -j 31225227 -o WorkDir%100
                                                                                             WorkDir 
---------------------------------------------------------------------------------------------------- 
                           /users/PZS0714/johrstrom/ondemand/src/apps/myjobs/data/projects/default/4 
                                                                                                     
                                                                                                     

```

[https://slurm.schedmd.com/sacct.html](https://slurm.schedmd.com/sacct.html)

Does LSF have a similar command to `sacct` with a similar field `WorkDir`?

---

<div class="post-metadata">

**Author:** ![dweise1776](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/dweise1776/32/1295_2.png) [@dweise1776](https://discourse.openondemand.org/u/dweise1776)\
**Post date:** [June 14, 2024, 7:30pm UTC](https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560/26 "2024-06-14T19:30:00Z")

</div>

Hi,  
Yes we do, it’s bacct. Here is the output of a failed job:  
Job \<29989850\>, Job Name , User , Project , Status  
, Queue \<foo\_normal\>, Command \<#!/bin/bash;#BSUB -q  
foo\_normal;#BSUB -J pythonjob #LSF Job Name;#BSUB -o pyt  
honjob.%J.out #Name of the job output file;#BSUB -e python  
job.%J.out #Name of the job error file;### – send notific  
ation at start --;#BSUB -B;### – send notification at com  
pletion --;#BSUB -N;module load python/3.10;env;pwd;python  
–version;python hello.py\>, Share group charged   
Fri Jun 14 10:48:59: Submitted from host , CWD \<$HOME\>, Output Fi  
le \<pythonjob.%J.out\>;  
Fri Jun 14 10:49:00: Dispatched to , Effective RES\_REQ \<select[type ==  
local] order[r15s:pg] affinity[core(1)\*1] \>;  
Fri Jun 14 10:49:00: Completed .

## Accounting information about this job: Share group charged CPU\_T WAIT TURNAROUND STATUS HOG\_FACTOR MEM SWAP 0.07 1 1 exit 0.0717 0M 0M CPU\_PEAK CPU\_EFFICIENCY MEM\_EFFICIENCY 0.00 0.00% 0.00%

SUMMARY: ( time unit: second )  
Total number of done jobs: 0 Total number of exited jobs: 1  
Total CPU time consumed: 0.1 Average CPU time consumed: 0.1  
Maximum CPU time of a job: 0.1 Minimum CPU time of a job: 0.1  
Total wait time in queues: 1.0  
Average wait time in queue: 1.0  
Maximum wait time in queue: 1.0 Minimum wait time in queue: 1.0  
Average turnaround time: 1 (seconds/job)  
Maximum turnaround time: 1 Minimum turnaround time: 1  
Average hog factor of a job: 0.07 ( cpu time / turnaround time )  
Maximum hog factor of a job: 0.07 Minimum hog factor of a job: 0.07  
Average expansion factor of a job: 1.00 ( turnaround time / run time )  
Maximum expansion factor of a job: 1.00  
Minimum expansion factor of a job: 1.00  
Total Run time consumed: 0 Average Run time consumed: 0  
Maximum Run time of a job: 0 Minimum Run time of a job: 0  
Scheduler Efficiency for 1 jobs  
Slot Utilization: - Memory Utilization: -

real 11m25.629s  
user 11m14.474s  
sys 0m10.728s

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [June 14, 2024, 7:34pm UTC](https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560/27 "2024-06-14T19:34:07Z")

</div>

> [@dweise1776](#):
>
> Fri Jun 14 10:48:59: Submitted from host , CWD \<$HOME\>, Output Fi  
> le \<pythonjob.%J.out\>;

Did you obfuscate this here? If I’m reading this right - the CWD when the job was submitted was the `$HOME`? Is the host field here the OOD web server or the submit\_host you’re sshing into?

---

<div class="post-metadata">

**Author:** ![dweise1776](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/dweise1776/32/1295_2.png) [@dweise1776](https://discourse.openondemand.org/u/dweise1776)\
**Post date:** [June 14, 2024, 10:24pm UTC](https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560/28 "2024-06-14T22:24:42Z")

</div>

> [@dweise1776](#):
>
> 29989850

Hi,  
Honestly I can’t remember if it was in home. It was probably /home/david/ondemand. In NEW news, I blew away the whole server, installed RHEL 8.10 and ondemand-3.1.4-1.el8.x86\_64. I also made the server a submit server for LSF. Let’s called this server vultannew. Let me get back to you on the results. Have a good weekend!  
–David

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/b/bae70bd0ed39a3ae769c2108155f4cb3e9da8385.png) [@system](https://discourse.openondemand.org/u/system)\
**Post date:** [December 11, 2024, 10:25pm UTC](https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560/29 "2024-12-11T22:25:31Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.openondemand.org/t/simple-question-execute-python-code-on-a-lsf-submit-host/3560.md?page=1)
