-
Notifications
You must be signed in to change notification settings - Fork 44
Added resource handler (ComponentResourceHandler
) for Components
#1763
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
Conversation
4e1da33
to
7795027
Compare
ComponentResourceHandler
) for Components
587599a
to
ee0bfc5
Compare
ComponentResourceHandler
) for ComponentsComponentResourceHandler
) for Components
a83edee
to
901d561
Compare
|
||
|
||
class AdapterResourceHandler: | ||
class ResourceHandler: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main logic of AdapterResourceHandler
is now in base class called ResourceHandler
. There are two sub classes AdapterResourceHandler
and ComponentResourceHandler
""" | ||
return f"{export['url']}" | ||
|
||
def _create_view_func(self, export: dict[str, str]) -> Callable: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The creation of the view function is slightly different between the two resource handlers. The most important difference is that there is only one instance of a Component
, while an Adapter handles several instance of HardwareObjects
. The hardware object id string is hence not needed for the Component
.
name, url_prefix, handler_dict, app, exports, commands, attributes | ||
) | ||
|
||
def _get_handler_object_route(self, export) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Adapters manage several instance of HardwareObjects, which means that need to be able to pass an id
67a4f26
to
9c763d0
Compare
hwr_logger = logging.getLogger("MX3.HWR") | ||
|
||
|
||
class Log(ComponentBase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.py in routes no longer needed, everything is contained in the Component
route definition and handler methods. The input and return data are serialized and handled the same way as for Adapters, making it much easier to handle the "data flow"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a great change, that works well with what is already in place.
There is only a misconfigured URL in the log.py
file. (The description should also say log.py
and not workflow.py
for those who are wondering:))
mxcubeweb/core/components/log.py
Outdated
{ | ||
"attr": "log_frontend_traceback", | ||
"method": "POST", | ||
"url": "/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This URL should be /log_frontend_traceback
9c763d0
to
0c16b47
Compare
0c16b47
to
9afba26
Compare
I've had this code for the
ComponentResourceHandler
more or less ready for some time and I decided that its time to at-least share it for input and ideas.The priority is still to migrate the components that are directly related to hardware objects to adapters, at-least where its feasible. That basically concerns all components except:
log
,csp_report
,login
,ra
,main
. The bigger components likequeue
andlims
may have to wait and remain components for some time.The concept is exactly the same as for the
AdapterResourceHandler
, and it was possible to re-use the same configuration/definition.The two classes
ComponentResourceHandler
andAdapterResourceHandler
shares the same base class which means that all the validation, serialization, exception handling of input and output are the same. It also means that theroutes
module as can be removed. No more route decorators 🥳 !For the sake of example I configured one component in log.py
Summary: