Example for retrieve_temporary_list

27 views
Skip to first unread message

Keilbart, Nathan Daniel

unread,
Sep 21, 2021, 1:56:32 AM9/21/21
to aiida...@googlegroups.com

Hello AiiDA community,

 

I have been working on developing a workflow that needs to download and parse files that can be quite large such as cube files. I came across the retrieve_temporary_list feature that seems to solve my issue as the information can be taken during parsing of a task. I have set the file that I want to have parsed and can find that it is correctly set when I load the node and call the get_retrieved_temporary_list() command. But when it gets to that part of the parser it only lists the default files that AiiDA downloads after finishing. Does the temporary list get set to a different variable? I am retrieving the files with retrieved.list_object_names() and would then attempt to open with rerieved.open but it doesn’t pass my check to make sure it’s in the list_object_names().

 

Is there perhaps a working example of this feature that someone could point me to? Currently, I have been looking at the documentation on this page which does not necessarily show all the options that need to possibly be enabled for it to work.

 

https://aiida.readthedocs.io/projects/aiida-core/en/latest/topics/calculations/usage.html#retrieve-temporary-list

 

Thank you for your future feedback. Please let me know if I can make any of my points more clear.

 

Nathan

 

-----------------------------------------------------------------------------------

Nathan Keilbart, PhD

Postdoctoral Research Scientist, Quantum Simulations Group

Lawrence Livermore National Laboratory

(925) 423-6620

-----------------------------------------------------------------------------------

 

Sebastiaan Huber

unread,
Sep 21, 2021, 2:24:38 AM9/21/21
to aiida...@googlegroups.com
Hi Nathan,

I had a look at the documentation, and it is indeed not clear how to actually use the `retrieved_temporary_list`.
I will open an issue and make sure it gets added.

The trick is that the `retrieved_temporary_folder` is just a temporary folder on the local hard disk.
It's full path is passed in the `kwargs` to the `Parse.parse` method.
You can retrieve it from there and operate it with normal Python file system tools.
For example:
import pathlib


def SomeParser(Parser):

    def parse(self, **kwargs):
        retrieved_temporary_folder = kwargs.get('retrieved_temporary_folder', None)

        if retrieved_temporary_folder is not None:
            retrieved_temporary_folder = pathlib.Path(retrieved_temporary_folder)  # Optional to use the modern `pathlib` module instead of `os`.

            for subpath in retrieved_temporary_folder.iterdir():
                if subpath.is_file():
                    subpath.read_bytes()
                    # or
                    with subpath(open) as handle:
                        data = handle.read()

As you can see you can treat it as a normal folder on disk.

HTH,

SPH
--
AiiDA is supported by the NCCR MARVEL (http://nccr-marvel.ch/), funded by the Swiss National Science Foundation, and by the European H2020 MaX Centre of Excellence (http://www.max-centre.eu/).
 
Before posting your first question, please see the posting guidelines at http://www.aiida.net/?page_id=356 .
---
You received this message because you are subscribed to the Google Groups "aiidausers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aiidausers+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aiidausers/9B575579-6354-4DA5-B072-8512E72E26CF%40llnl.gov.

Keilbart, Nathan Daniel

unread,
Sep 22, 2021, 8:09:54 PM9/22/21
to aiida...@googlegroups.com

Thank you for the description Sebastiaan. I was able to piece together a workfunction with this capability and it is proving to be advantageous. Thank you for your time and effort.

Reply all
Reply to author
Forward
0 new messages