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

Workflow, queue_model_objects - Fixing imports, making sure we can import queue_model_objects standalone #881

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

marcus-oscarsson
Copy link
Member

It was decided long ago that the queue_model_objects should be importable as it is and not contain or contain as little logic as possible, and contain classes only carrying data. We have deviated from the later but the module still needs to be importable without the rest of mxcubecore or non standard library dependencies.

@marcus-oscarsson marcus-oscarsson changed the title Workflow - queue_model_objects - Fixing imports, making sure we can import queue_model_objects standalone Workflow, queue_model_objects - Fixing imports, making sure we can import queue_model_objects standalone Mar 18, 2024
Copy link
Collaborator

@rhfogh rhfogh left a comment

Choose a reason for hiding this comment

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

Well, it is importable - all the import statements are in function calls. It may well be that this should be refactored, but for now I was planning to postpone that until we are changing the queue anyway (and moving over to Pydantic classes).

Anyway, approved - but if you want this checked at the top of the file maybe you should add this to the 'try' statement:

    from mxcubecore.HardwareObjects.Gphl import GphlMessages

@marcus-oscarsson
Copy link
Member Author

The import in the function definitions are fine I think the issue Olof had here is that as its supposed to work standalone he had only this file and queue_model_enumerables, so the rauml import fails. We can leave the other imports as they are for the moment, but I don't mind following up wit another PR if you think its worth doing.

@rhfogh
Copy link
Collaborator

rhfogh commented Mar 18, 2024

Maybe I could fix this if I understood the problem a bit better. AFAIAC there are certain actions that have to happen at certain points, when the functions that contain the imports are called. One could probably move the functionality to the calling functions in GphlWorkflow instead, but the same actions would still have to happen at the same time. Or, if that was impossible, it would be a major problem to reorganise. The yaml import, specifically, is only for a specific mock test scenario, so that would be dealt with more easily - if I was more sure exactly what the constraints are.

@marcus-oscarsson
Copy link
Member Author

The original idea was that queue_model_objects is supposed to be importable as it is and used by any software that wants to add queue models to the queue. In the first version of XMLRPCServer the file queue_model_objects.py was serialized and sent as part of the initialization process.

The code still exists, queue_get_model_code

The BES Workflows are still using this idea but we have been discussing to move away from this approach and favor a different kind of API. So this file is used by the workflow without the rest of MXCuBE or any specific dependency hence the issuer with for instance rauml. Anything that is specific to your workflows and are within a def does not pose a problem.

@marcus-oscarsson marcus-oscarsson merged commit d54ea9e into develop Mar 19, 2024
10 checks passed
@marcus-oscarsson marcus-oscarsson deleted the mo-wf-imports branch March 19, 2024 07:53
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