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

Overload PortNamespace mutable properties upon exposing #1635

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Jun 8, 2018

Fixes #1634

Note: relies on fixes in plumpy that have not yet been released.

When exposing the ports of a process one would expect that the
receiving port namespace would not just inherit the ports but
also the mutable properties of the PortNamespace, such as the
default, valid_type, help, validator and required attribute.
Therefore the _expose_ports method is adapted to overload the
mutable properties from the source namespace to the target
namespace.

The method now also takes an optional dictionary namespace_options
which can be used to override even the properties of the source
namespace. If the ports are exposed into a namespace that does not
yet exist in the target namespace, it will be constructed using
this namespace_options dictionary as constructor keyword arguments.
Note that these namespace options will not be used for any sub
namespace that will have to be created along the way, nor will they
be used to override any of the properties of already existing sub
namespaces

@sphuber sphuber requested review from muhrin and greschd June 8, 2018 16:55
greschd
greschd previously approved these changes Jun 10, 2018
Copy link
Member

@greschd greschd left a comment

Choose a reason for hiding this comment

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

Are the fixes in plumpy the reason why the tests still fail? Otherwise looks good to me, feel free to merge when the tests pass.

@sphuber
Copy link
Contributor Author

sphuber commented Jun 11, 2018

Yes plumpy needs to be released and then I will update the requirement

@sphuber sphuber force-pushed the fix_1634_pass_namespace_construction_args_through_expose branch from eb85fa5 to fdff746 Compare June 21, 2018 15:12
@sphuber sphuber force-pushed the fix_1634_pass_namespace_construction_args_through_expose branch 2 times, most recently from 155ce7c to 5ccf592 Compare June 21, 2018 16:03
When exposing the ports of a process one would expect that the
receiving port namespace would not just inherit the ports but
also the mutable properties of the PortNamespace, such as the
default, valid_type, help, validator and required attribute.

The method that was responsible for creating the new namespace
and exposing the ports, ProcessSpec._expose_ports, failed to do
this. However, plumpy already defined a method that did just
this, PortNamespace.absorb(). To fix this problem, we decided
to move the expose functionality to plumpy and leverage the
absorb method, which already properly overloaded mutable
properties of the donor namespace to the host namespace.

The only other addition is that the implementation of exposing
ports in plumpy did not yet have a memory, as required by the
implementation in aiida-core. This implementation, along with
the proper namespace property inheritance has now been released
with plumpy v0.10.3, which is the new dependency.

The expose methods in plumpy now also takes an optional dictionary
namespace_options which can be used to override even the properties
of the source namespace that would be inherited. If the ports are
exposed into a namespace that does not yet exist in the target
namespace, it will be constructed using this namespace_options
dictionary as constructor keyword arguments. Note that these
namespace options will *not* be used for any sub namespaces that
will have to be created along the way, nor will they be used to
override any of the properties of already existing sub namespaces.
@sphuber sphuber force-pushed the fix_1634_pass_namespace_construction_args_through_expose branch from 5ccf592 to 458ea02 Compare June 21, 2018 16:04
@codecov-io
Copy link

codecov-io commented Jun 21, 2018

Codecov Report

Merging #1635 into develop will increase coverage by 0.04%.
The diff coverage is 83.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #1635      +/-   ##
==========================================
+ Coverage    57.06%   57.1%   +0.04%     
==========================================
  Files          275     274       -1     
  Lines        33923   33874      -49     
==========================================
- Hits         19357   19343      -14     
+ Misses       14566   14531      -35
Impacted Files Coverage Δ
aiida/work/exceptions.py 100% <100%> (ø) ⬆️
aiida/work/launch.py 91.3% <100%> (+0.39%) ⬆️
aiida/work/ports.py 100% <100%> (ø) ⬆️
...orm/implementation/general/calculation/__init__.py 78.57% <100%> (ø) ⬆️
aiida/work/futures.py 97.14% <100%> (+0.08%) ⬆️
aiida/work/process_spec.py 100% <100%> (+2.94%) ⬆️
aiida/work/context.py 75% <100%> (+2.27%) ⬆️
...ida/orm/implementation/general/calculation/work.py 90% <100%> (ø) ⬆️
aiida/work/transports.py 45% <22.22%> (ø) ⬆️
aiida/work/process_builder.py 87.5% <70%> (+0.83%) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2a8269...458ea02. Read the comment docs.

@sphuber sphuber merged commit da10680 into aiidateam:develop Jun 21, 2018
@sphuber sphuber deleted the fix_1634_pass_namespace_construction_args_through_expose branch June 21, 2018 16:34
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.

Overload the mutable properties of a PortNamespace when exposing it
4 participants