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

First prototype of a code base #14

Closed
wants to merge 9 commits into from
Closed

Conversation

agoscinski
Copy link
Collaborator

@agoscinski agoscinski commented Jul 22, 2024

This is PR #12 with some additional changes that is based from the init-repo, so we can separate the repo structure and code base initialization. The module structure is

src
└── wcflow
    ├── core.py
    ├── __init__.py
    ├── _utils.py
    ├── wc
    │   ├── _classes.py
    │   ├── __init__.py
    │   └── _schema.py
    └── workgraph.py

The rough idea is that everything in the wc submodule is related to parsing of the file and converting it to a core.Workflow. The core.Workflow has all information to allow a convenient unrolling of the tasks over the periods. The workgraph.* is responsible for creating an AiiDA workgraph from a core.Workflow.

TODOs/Issues:

  • At the moment we run verdi presto before the tests to set up a profile, would be nicer if we could set up a profile within the tests
  • sphinx -> mkdocs

@agoscinski agoscinski force-pushed the init-repo branch 2 times, most recently from b35576c to 2805125 Compare July 24, 2024 08:37
@agoscinski agoscinski force-pushed the init-repo-code branch 2 times, most recently from a505b48 to c392d73 Compare July 24, 2024 10:02
@agoscinski
Copy link
Collaborator Author

Notes from the meeting with @leclairm


We go with the schema library and pyaml, ditching strictyaml, because the anchors are still useful for our case.


We might want to change naming to

wc.Data -> wc.DataSpec
core.Data -> core.DataSpec
core.UnrolledData -> core.Data

@leclairm will rethink this


Some thoughts about relaxing the logic that a lagged date is only enforced if it is after the start_date

inputs:
  - icon_input:
    lag:
      condition: "possible" # other options could be "always" so the file should always exist
      value: '-P4M'

But for now it is okay

Copy link
Collaborator

@GeigerJ2 GeigerJ2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, went once through the whole thing. Again, great work, @agoscinski! 🚀 A lot to digest, so I might have missed things. My comments consist mainly of questions for myself that would be nice to discuss for clarification.

As mentioned on Slack, when running the example, it's stuck. This might be the bug I found in the AiidaWorkGraph, where for output in task.unrolled_inputs:. Will test tomorrow. Apart from that, once we settle the strictyaml discussion, I'd say LGTM, and then we can further iterate.

examples/README.rst Outdated Show resolved Hide resolved
icon:
inputs:
- grid_file:
arg_option: "-g"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't be needed with actual ICON, I suppose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How we integrate plugins is still an open question. But with the aiida builder we can get call input arguments and could technically support them, at least we can specify all orm data types that can be specified in a yaml file which should be most of them.

class TimeUtils:
@staticmethod
def duration_is_less_equal_zero(duration: Duration) -> bool:
if (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just <=?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not so easy to see on first glance but if the condition is: Even all are zero¿ or any is less than zero. If you do <= with the connection with and conditions, then all would need to be less than zero, so (-1, 1, 1, 1, 1, 1) would note be fulfilled. If you use or, then once one is zero the condition is already fulfilled, so (0, 1, 1, 1, 1, 1) would be fulfilled.

@@ -0,0 +1,21 @@
import argparse

from aiida.manage.configuration import load_profile
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just do from aiida import load_profile?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My pyright was unhappy with that^^. I general prefer for source code to be more verbose with their modules, but no strong opinions.


aiida_workgraph = workgraph.AiidaWorkGraph(core_workflow)
print("Starting workflow please run `workgraph web start` in another terminal to start a GUI as webservice.") # noqa: T201
result = aiida_workgraph.run()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work with submit()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should work. It is just that then one needs to have rabbitmq for running the tests. Therefore I thought to switch to pixi, since there I can install all this in the background so nonaiida user do not need to bother.

def __init__(
self,
name: str,
inputs: list[str | dict] | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Task class doesn't have inputs and outputs? Is Task like a raw representation, directly from the YAML file? I suppose CycleTask has a different purpose, as it also doesn't inherit from Task? Maybe you can explain in the meeting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Task like a raw representation, directly from the YAML file?

Yes the class CycleTask represents a task in a cycle, while the python class Task represents a task definition outside of the cycles.

Should add this to the doc.


class Cycle(_NamedBase):
"""
We never need to create instances of a cycle class so we only contains static methods
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can explain in the meeting.

src/wcflow/wc/_classes.py Outdated Show resolved Hide resolved
src/wcflow/workgraph.py Outdated Show resolved Hide resolved
@@ -0,0 +1,39 @@
#!/usr/bin/env python
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be also under tests? Same script as for the example, right? It's here to then also be used for testing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is used in the tests (see the test_config_small.yaml). I think need remove icon.sh and icon as they are not used anymore. Need to verify that they are not needed.

src/wcflow/wc/_classes.py Outdated Show resolved Hide resolved
@agoscinski
Copy link
Collaborator Author

There was a small bug in the UnrolledDependency (used from variable) that has been fixed. The example should work now.

Co-authored-by: Julian Geiger <[email protected]>
@agoscinski agoscinski changed the title Initialize code base First prototype of a code base Nov 27, 2024
@agoscinski agoscinski closed this Nov 27, 2024
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.

2 participants