-
Notifications
You must be signed in to change notification settings - Fork 5
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
Failed to get required imports for function #175
Comments
There is an error when the WorkGraph tries to inspect the type annotations, and it fails to inspect the
This should be a bug. I will try to fix it this morning. For the moment, you can remove the type annotations, and try. There are three possible solutions for the list outputs.
def generate_structures(
structure: Atoms,
strain_lst: list
) -> list[Atoms]:
structure_dict = {}
for strain in strain_lst:
structure_strain = structure.copy()
structure_strain.set_cell(
structure_strain.cell * strain**(1/3),
scale_atoms=True
)
structure_dict[f"strain_{strain}"] = structure_strain
return structure_dict
decorated_function = task.pythonjob(outputs=[{"name": "structure_dict", "identifier": "Namespace"}])(generate_structures)
What do you think? |
The previous code has the assumption that all type hints which have an __origin__ attribute also possess an _name attribute. This is not true for certain built-in generic types like list, dict, etc. in Python, particularly when accessed via the __origin__ attribute, which is a legacy of Python's type hinting evolution.
While trying the nice new
pythonjob
decorator:No error is raised, but the following message is printed:
The
generate_structures
function is the following:I'm assuming the issue is the returned
list
? This issue also made me wonder how to deal withlist
outputs. The user here would probably want to have a list of linkedAtomsData
nodes, but I suppose that is not what will happen. Off the top of my head, I'm considering if the decorator function should have some kind of input argument that allows the user to specify that the list should be expanded as several linked output nodes.The text was updated successfully, but these errors were encountered: