Skip to content

Search for model-specific tasks#698

Open
mranst wants to merge 4 commits intodevelopfrom
fix/mranst/model_tasks
Open

Search for model-specific tasks#698
mranst wants to merge 4 commits intodevelopfrom
fix/mranst/model_tasks

Conversation

@mranst
Copy link
Collaborator

@mranst mranst commented Feb 5, 2026

Description

Addressing comments in #626, this allows for tasks that exist only in certain model-specific folders to be called. If these tasks are called from a different model and don't have counterpart for that model or a generic version, it will fail. In my opinion, this is the best way to handle this, and we should handle tasks only existing for certain models by baking that logic into the scheduling in flow.cylc, i.e:

{% for model_component in model_components %}
{% if model_component == 'geos_atmosphere' %}
GenerateObservingSystemRecords-{{model_component}}
{% endif %}
{% endfor %}

Though this is somewhat complicated so I'm open to alternatives. This doesn't necessarily need #656 to work, since the scheduling is still templated in jinja there

@mranst mranst requested a review from Dooruk February 5, 2026 21:22
@Dooruk
Copy link
Collaborator

Dooruk commented Feb 6, 2026

{% for model_component in model_components %}
{% if model_component == 'geos_atmosphere' %}
GenerateObservingSystemRecords-{{model_component}}
{% endif %}
{% endfor %}

Though this is somewhat complicated so I'm open to alternatives. This doesn't necessarily need #656 to work, since the scheduling is still templated in jinja there

i guess at that point it would be

{% for model_component in model_components %}
{% if model_component == 'geos_atmosphere' %}
GenerateObservingSystemRecords-geos_atmosphere
{% endif %}
{% endfor %}

Did you start testing these model specific folders? I'm wondering how would it work in terms of listing available tasks; swell task --help if only generic, model-specific or both tasks exist?

I was able to use geos_marine specific task in my other gcm_run.j PR but I do like this solution you are proposing here rather than running and skipping tasks unnecessarily and crowding cylc workflow.

Also GPT suggested module names cannot contain hyphens (-). in regards to importlib, so use _ instead but this hasn't created a problem for me. Something to keep in mind I suppose.

@mranst
Copy link
Collaborator Author

mranst commented Feb 6, 2026

Did you start testing these model specific folders? I'm wondering how would it work in terms of listing available tasks; swell task --help if only generic, model-specific or both tasks exist?

I was able to use geos_marine specific task in my other gcm_run.j PR but I do like this solution you are proposing here rather than running and skipping tasks unnecessarily and crowding cylc workflow.

It will list all tasks that are specified in an abstract sense. If you have both:

src/swell/tasks/task_example.py
src/swell/tasks/geos_marine/task_example-geos_marine.py

you will have TaskExample in the available tasks, same as if only one or the other exists. Yet another possible point of confusion, it'd be up to the user to make sure the proper versions for the tasks are being called in flow.cylc.

Also GPT suggested module names cannot contain hyphens (-). in regards to importlib, so use _ instead but this hasn't created a problem for me. Something to keep in mind I suppose.

I've tested this and had no problem with hyphens, but that is against PEP guidelines so I've changed it

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