-
Notifications
You must be signed in to change notification settings - Fork 11
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
✨ Xircuits Context #109
✨ Xircuits Context #109
Conversation
Thanks for the review!
Really good question, thanks for asking!
And
Here's the modified components gist: |
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.
Tested and it's working as expected. Thanks for answering my question.
input_str = self.input_str.value if self.input_str.value else ctx['comp_str'] comp_str
Though, I think there a typo with the last comp_str
. Once I remove that, it's working fine.
I just realized that this context
can create a huge list of dict
where any component can access that dict
. Which is great..I think. From what I understood, I thought to access that context
, we've to specify which component is the context
is from like CompulsoryHyperparameter::comp_str
(from what I remember how Mr. Eduardo did it).
Anyway, I'll merge this first.
Description
This pull request introduces xircuits context (ctx),which allows users to pass data to another components in the form of a python dict.
Previously to pass any type of data, the user needs to be explicitly code it via outPort to inPorts. This would be cumbersome especially if it's a global variable that might be used everywhere, such as the experiment name. By using ctx, users simply need to add it in their execute section. Here is a basic syntax:
I have added the
HelloContext
component to the example components library for you to try.Pull Request Type
Type of Change
Tests
Ensure that ctx can be accessed by all components
You may also try out this xircuit.
Expected Output:
Ensure that previous components are still working
Tested on?
Notes
As the ctx parameter needs to be passed in, I had to update every component in this pull request. You will need to pull a fresh copy / not use your old component library.