-
Notifications
You must be signed in to change notification settings - Fork 532
[MAINT] Cleanup EngineBase #2376
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6ca1489
[MAINT] Cleanup engine/base
oesteban 47345da
update changes
oesteban 11e42ea
refactoring tests
oesteban 301fc4b
fix tests
oesteban b5f8537
sty
oesteban 9a6e7cb
remove install_aliases
oesteban 1d38127
fix error type
oesteban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# -*- coding: utf-8 -*- | ||
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- | ||
# vi: set ft=python sts=4 ts=4 sw=4 et: | ||
from __future__ import print_function, unicode_literals | ||
|
||
import pytest | ||
from ..base import EngineBase | ||
from ....interfaces import base as nib | ||
|
||
|
||
class InputSpec(nib.TraitedSpec): | ||
input1 = nib.traits.Int(desc='a random int') | ||
input2 = nib.traits.Int(desc='a random int') | ||
input_file = nib.traits.File(desc='Random File') | ||
|
||
|
||
class OutputSpec(nib.TraitedSpec): | ||
output1 = nib.traits.List(nib.traits.Int, desc='outputs') | ||
|
||
|
||
class EngineTestInterface(nib.BaseInterface): | ||
input_spec = InputSpec | ||
output_spec = OutputSpec | ||
|
||
def _run_interface(self, runtime): | ||
runtime.returncode = 0 | ||
return runtime | ||
|
||
def _list_outputs(self): | ||
outputs = self._outputs().get() | ||
outputs['output1'] = [1, self.inputs.input1] | ||
return outputs | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'name', ['valid1', 'valid_node', 'valid-node', 'ValidNode0']) | ||
def test_create(name): | ||
base = EngineBase(name=name) | ||
assert base.name == name | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'name', ['invalid*1', 'invalid.1', 'invalid@', 'in/valid', None]) | ||
def test_create_invalid(name): | ||
with pytest.raises(ValueError): | ||
EngineBase(name=name) | ||
|
||
|
||
def test_hierarchy(): | ||
base = EngineBase(name='nodename') | ||
base._hierarchy = 'some.history.behind' | ||
|
||
assert base.name == 'nodename' | ||
assert base.fullname == 'some.history.behind.nodename' | ||
|
||
|
||
def test_clone(): | ||
base = EngineBase(name='nodename') | ||
base2 = base.clone('newnodename') | ||
|
||
assert (base.base_dir == base2.base_dir and | ||
base.config == base2.config and | ||
base2.name == 'newnodename') | ||
|
||
with pytest.raises(ValueError): | ||
base.clone('nodename') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 meant not to bother removing or reordering, and just tolerate the PEP8 violation. Unless it's causing problems, let's not change this here.
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've checked locally with Python 2 and this aliases are not necessary. Let's get rid of them whenever possible.
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.
@oesteban @effigies I'm not sure if I understand, does
standard_library.install_aliases()
at the end of the import block (e.g. in node.py or workflow.py) changes anything?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 don't believe it does.