Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Added code to support Singularity on HiperGator #389

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ __pycache__/
.tox/
.cache/
htmlcov/
build/
.eggs

29 changes: 29 additions & 0 deletions examples/plugin_example/gwexample/analyses/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,32 @@ def fibonacci(n):
if n == 1 or n == 2:
return 1
return fibonacci(n-1) + fibonacci(n-2)

@app.task
# @argument('image_name', 'slide_name', 'path')
def nuclei(image_name, slide_name, path):
"running nuclei"
print(app, '++++++++++')
if path:
print('using arg path !!')
os.chdir(path)
else:
print('using default path !!')
os.chdir('/home/rc-svc-pinaki.sarder-web/digital_slide_archive/devops/singularity-minimal')
print('Current Path => ', os.getcwd())
path = os.getcwd()
flags = os.O_RDWR | os.O_CREAT
sif_image = os.open('sarderlab_histomicstk_latest.sif', flags)
sif_image_path = path + image_name if image_name else '/sarderlab_histomicstk_latest.sif'
slide_image = os.open(slide_name, flags)
slide_image_path = path + slide_name if slide_name else '18-142_PAS_1of6.svs'
output = os.open('Nuclei-outputNucleiAnnotationFile.anot', flags)
output_path = path + '/Nuclei-outputNucleiAnnotationFile.anot'
run_container = f'apptainer run --pwd /HistomicsTK/histomicstk/cli {sif_image} NucleiDetection {slide_image} {output}'
try:
res = subprocess.call(f'apptainer run --pwd /HistomicsTK/histomicstk/cli {sif_image_path} NucleiDetection {slide_image_path} {output_path}', shell=True, bufsize=0,stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="UTF8")
print(res, '----1')

except Exception as e:
print(f"Exception occured {e}")

3 changes: 2 additions & 1 deletion girder_worker/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def gw_task_prerun(task=None, sender=None, task_id=None,
raise

try:
task.girder_client = GirderClient(apiUrl=task.request.girder_api_url)
#task.girder_client = GirderClient(apiUrl=task.request.girder_api_url)
task.girder_client = GirderClient(apiUrl='http://0.0.0.0:8101/api/v1')
task.girder_client.token = task.request.girder_client_token
except AttributeError:
task.girder_client = None
Expand Down
21 changes: 21 additions & 0 deletions girder_worker/docker/nvidia.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
def is_nvidia_image(api, image):
labels = api.inspect_image(image).get('Config', {}).get('Labels')
return bool(labels and labels.get('com.nvidia.volumes.needed') == 'nvidia_driver')

def set_nvidia_params(kwargs:dict,singularity_command:list,gpus:int=1):
'''
This function is used to set the gpu parameters based on the user input and plugin job.

Parameters:
kwargs (dict, required): The keyword arguments dictionary sent to the celery task as an input, part of the request

singularity_command (list, required): A list that container all the arguments to construct a singularity command that will be sent to the HPC job

gps (int, optional): If the plugin doesn't have a --gpu parameter in contianer_args, then a default of 1 gpu is allocated, else the user specified number of gpus is allocated.

Returns:
None
'''
kwargs['--gres'] = f"gres:gpu:a100:{gpus}" if gpus > 1 else f"gres:gpu:a100:1"
kwargs['--partition'] = 'gpu'
kwargs['--mem'] = '32000'
#Reducing CPU count for gpu-based job for resource conservation
kwargs['--cpus-per-task'] = '8'
singularity_command.append('--nv')
Loading