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

QueryBuilder does not have a with_calling_ancestor filter to get called calculations from a top workflos #4992

Open
JPchico opened this issue Jun 18, 2021 · 0 comments
Labels
type/feature request status undecided

Comments

@JPchico
Copy link
Contributor

JPchico commented Jun 18, 2021

As mentioned in the aiidausers group discusssion sometimes one wants to find the underlying CalcJobNodes which is the child of several nested WorkChainNode. When one wants to do this, one must append a series of queries traversing each of the children of the top level WorkChainNode until one reaches the underlying CalcJobNodes

_qb = orm.QueryBuilder()
_qb.append(
    orm.Node,
    filters={
        'and':[
            {'node_type': {'ilike':'process.workflow.workchain.WorkChainNode.%'}}
        ]
   },
tag='workchain'
)
_qb.append(orm.Node, with_incoming='workchain', tag='workchain_1')
_qb.append(orm.Node, with_incoming='workchain_1', tag='workchain_2')
_qb.append(orm.Node, with_incoming='workchain_2', tag='workchain_3')
_qb.append(orm.CalcJobNodes, with_incoming='workchain_3')

Ideally one would like to have a query like the following

_qb = orm.QueryBuilder()
_qb.append(
    orm.Node,
    filters={
        'and':[
            {'node_type': {'ilike':'process.workflow.workchain.WorkChainNode.%'}}
        ]
   },
tag='workchain'
)
_qb.append(orm.CalcJobNodes, with_calling_ancestor='workchain')

where one would obtain all the underlying CalcJobNodes of the top-level WorkChainNode with only one extra append call, i.e. one does not need to know how many levels deep the CalcJobNodes is with respect to the WorkChainNode.

To do this one would need to perform similar recursive SQL queries as in #3755

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature request status undecided
Projects
None yet
Development

No branches or pull requests

1 participant