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

process_state can be None when we attempt to probe it #6682

Open
edan-bainglass opened this issue Jan 2, 2025 · 3 comments
Open

process_state can be None when we attempt to probe it #6682

edan-bainglass opened this issue Jan 2, 2025 · 3 comments
Labels

Comments

@edan-bainglass
Copy link
Member

edan-bainglass commented Jan 2, 2025

Describe the bug

In aiida.cmdline.utils.ascii_vis.calc_info, we attempt node.process_state.value.capitalize(). However, process_state may be None, in which case this will except.

Steps to reproduce

See aiidalab/aiidalab-widgets-base#657 for details.
I suppose try calling the utility immediately after starting a process.

Expected behavior

Obtaining the process state if available.

Your environment

AiiDAlab container (aiidalab/full-stack:latest image)

Comments

I believe node.process_state.value.capitalize() is already available via node.process_state.name

@unkcpz
Copy link
Member

unkcpz commented Jan 2, 2025

This is the process_state of process node rather than the process object (which run in runner) itself. Therefore I think it makes sense to allow it to be None (see below the process_state property method of process node orm). It can happen when the the store is called but the process_state is not yet finish set? Or it is possible to make the storing of a process state as an atomic transaction to avoid the process state to be None?

    @property
    def process_state(self) -> Optional[ProcessState]:
        """Return the process state

        :returns: the process state instance of ProcessState enum
        """
        state = self.base.attributes.get(self.PROCESS_STATE_KEY, None)

        if state is None:
            return state

        return ProcessState(state)

From plumpy point of view, when the process object (process in runner) created, it automatically enters into the create state so in principle the process_state of object cannot be None (but the process_state of node can be None).

@edan-bainglass
Copy link
Member Author

To be clear, this issue is not about if None is or isn't allowed. It simply points out that in aiida.cmdline.utils.ascii_vis.calc_info, we are assuming that process_state is not None, where it can clearly be None.

@agoscinski
Copy link
Contributor

agoscinski commented Jan 9, 2025

We fixed it for build_call_graph #6590 (resulting from issue #6585) seems like we need to look through all the functions in the module to see if it is probably handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants