| This algorithm is part of VANTAGE6. A docker build of this algorithm can be obtained from harbor.vantage6.ai/algorithms/utils |
Collection of tools that can be used on vantage6-nodes.
fetch_static_file- Obtain a static file from the nodelist_static_files- List static files on the node
from vantage6.client import Client # Create, athenticate and setup client client = Client("http://127.0.0.1", 5000, "") client.authenticate("[email protected]", "password") client.setup_encryption(None) # Define algorithm input input_ = { "method":"fetch_static_file", "args": [], "kwargs": {'filename': 'name_of_the_static_file.pdf'} # optional argument } # Send the task to the central server task = client.task.create( name="testing", image="harbor.vantage6.ai/algorithms/utils", collaboration=1, input=input_, description="Human readable description", organizations=[2] ) # Retrieve the task information task_info = client.task.get(id_=task.get("id"), include_results=True) # Retrieve the result (file in this case) res = client.result.get(task_info['results'][0]['id']) result = res['result'] # Write the bytes to a file with open('name_of_the_static_file.pdf', 'wb') as f: f.write(result)
from vantage6.client import Client # Create, athenticate and setup client client = Client("http://127.0.0.1", 5000, "") client.authenticate("[email protected]", "password") client.setup_encryption(None) # Define algorithm input input_ = { "method":"list_static_files", "args": [], "kwargs": {'extension': ['.pdf']} # optional argument, otherwise use: "kwargs": {} } # Send the task to the central server task = client.task.create( name="testing", image="harbor2.vantage6.ai/algorithms/utils", collaboration=1, input=input_, description="Human readable description", organizations=[2] ) # Retrieve the task information task_info = client.task.get(id_=task.get("id"), include_results=True) # Retrieve the result (file in this case) res = client.result.get(task_info['results'][0]['id']) result = res['result']
The algorithm looks by default in the /mnt/data folder. It is possible to let the algorithm use a different folder by specifying the algorithm environment variable STATIC_FOLDER. It is also possible to specify a default file name by setting STATIC_FILENAME. Note that the user argument filename has priority. Add the block algorithm_env to the node configuration file to do so:
application: ... algorithm_env: STATIC_FOLDER: /mnt/data/some/other/folder STATIC_FILENAME: filename.txt ...
