Girder Worker with Girder: a missing link / a linking issue

Thanks for your help David. I have been able to run the fibonacci jobs inside Girder. I still have some trouble to get the result of my job. Please correct me if I’m wrong.

I can either run:

async_result = fibonacci.delay(26)
    
# Print the result of fib call
print(async_result.get())

but in this case I lose the interesting part with the asynchronous part. To overcome this limitation, once the job is launched I need to use the mecanism with GirderUploadToItem (explained in girder_worker/TRANSITION.md at master · girder/girder_worker · GitHub). Unfortunately, the task is running without the GirderUploadToItem while it returns an error message with. Could you suggest why. In case, I indicate the relevant code/log on.

Additionally, what would be the most appropriate way to retrieve the log and status during the task (like simple print) ?

Thanks
Best
Valéry


Producer girder server inside a plugin

dict_with_file_information['itemId']  

return

ObjectId('61eee9b6d255641bb0bf0dd5')
def call_girder_worker_outpath(number, item_id):
   #async_result = fibonacci.delay(  number,  girder_job_title="A Custom Job Title")
    # Create a token with permissions of the current user.
   token = Token().createToken(user=getCurrentUser()) 

   async_result =make_matplotlib.delay(99,
    girder_job_title='Upload images Job',
	girder_job_type='my_custom_type',
	girder_job_public=True,
        girder_client_token=token['_id'], 
         girder_result_hooks=[
		GirderUploadToItem(
            str(item_id),
            delete_file=True
        ),
	])

   return async_result.job

Consumer side task:

@app.task
@argument( 'n', types.Integer, min=1)
def make_matplotlib(n):
    """Make a matplotlib figure."""
    print(n)
    output_path='/tmp/figure_1_stream_angle_all_co_all_direction_0_zoom_view_plane_0_0000.png'
    return output_path 

error message

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/valeryozenne/Dev/Girder/test-girder/lib/python3.8/site-packages/hello_world/__init__.py", line 267, in call_girder_worker_outpath
    GirderUploadToItem(
  File "/home/valeryozenne/Dev/Girder/test-girder/lib/python3.8/site-packages/girder_worker_utils/transforms/girder_io.py", line 140, in __init__
    super(GirderUploadToItem, self).__init__(**kwargs)
  File "/home/valeryozenne/Dev/Girder/test-girder/lib/python3.8/site-packages/girder_worker_utils/transforms/girder_io.py", line 44, in __init__
    token = getCurrentToken()['_id']
TypeError: 'NoneType' object is not subscriptable