Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump pytest to read pyproject.toml #71

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ltalirz
Copy link
Member

@ltalirz ltalirz commented Apr 30, 2021

No description provided.

@ltalirz
Copy link
Member Author

ltalirz commented May 3, 2021

I've removed one low-level access to the repository, but there is another one in
https://github.com/yakutovicha/aiida-raspa/blob/5aaaaca680dd08404eb099b6e61b39b982d17c6a/aiida_raspa/calculations/__init__.py#L171-L208

For this one I'd be grateful for some help

  • @yakutovicha What exactly is happening in this function?
  • @sphuber How would one translate this to the new implementation?

@sphuber
Copy link

sphuber commented May 3, 2021

@sphuber How would one translate this to the new implementation?

Your best bet is to use the Repository.walk method, which mimics the behaviour of os.walk. I just noticed that I haven't exposed this on the node level through the NodeRepositortyMixin yet. I will open a PR to fix this. Once that is done, you would be able to do something like:

for root, dirnames, filename in self.inputs.retrieved_parent_folder.walk():
    filepath = root / filename
    content = self.inputs.retrieved_parent_folder.get_object_content(filepath)
   # Then write content to the destination folder using normal Python file system tools as I assume `dest_folder` is an instance of `aiida.common.folders.Folder` and so sits on the local file system.

Just realize that this approach won't work if you want to have the plugin also compatible with 1.x because Node.walk won't exist there either. You can always just use Node.list_objects to get the objects. You just have to do the recursing into directories yourself to find all files. There is no single recursive function that does it for you in the API of aiida-core==1.x unfortunately

@yakutovicha
Copy link
Collaborator

This function copies Restart folder into RestartInitial, so that RASPA can restart from it. Also, parameters like pressure and temperature are adapted to the new calculation.

@ltalirz
Copy link
Member Author

ltalirz commented May 6, 2021

I just noticed that I haven't exposed this on the node level through the NodeRepositortyMixin yet. I will open a PR to fix this.

Thanks @sphuber , feel free to ping me on the PR.
Until then, can I use repository.walk and pass it some information from the retrieved_parent_folder?

filepath = root / filename

The dirnames can be ignored?

Also, do you think it would make sense to provide a drop-in replacement for copytree?
I can imagine that people may want to do that from time to time...

@sphuber
Copy link

sphuber commented May 7, 2021

I just noticed that I haven't exposed this on the node level through the NodeRepositortyMixin yet. I will open a PR to fix this.

Thanks @sphuber , feel free to ping me on the PR.
Until then, can I use repository.walk and pass it some information from the retrieved_parent_folder?

Yes, but only in aiida-core>=2.0

filepath = root / filename

The dirnames can be ignored?

I think that if you use put_object_from_* any intermediate sub paths will be automatically created, so there is no need to manually create subdirectories before writing files to them.

Also, do you think it would make sense to provide a drop-in replacement for copytree?
I can imagine that people may want to do that from time to time...

Yes, I think this might be useful: aiidateam/aiida-core#4928

@mpougin mpougin force-pushed the main branch 2 times, most recently from 152abd7 to 9e7a770 Compare August 27, 2023 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants