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

BUG: Move handling of context arguments after handling of .depends keyword #465

Merged
merged 11 commits into from
Sep 8, 2021
6 changes: 2 additions & 4 deletions skypy/pipeline/_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ def __init__(self, configuration):
self.dag.add_node(job, skip=False)
if isinstance(settings, Item):
items[job] = settings
# infer additional item properties from context
settings.infer(context)
for table, columns in self.table_config.items():
table_complete = '.'.join((table, 'complete'))
self.dag.add_node(table_complete)
Expand All @@ -115,8 +113,6 @@ def __init__(self, configuration):
self.dag.add_edge(job, table_complete)
if isinstance(settings, Item):
items[job] = settings
# infer additional item properties from context
settings.infer(context)
# DAG nodes for individual columns in multi-column assignment
names = [n.strip() for n in column.split(',')]
if len(names) > 1:
Expand All @@ -138,6 +134,8 @@ def __init__(self, configuration):
while c:
self.dag.add_edge(c, d)
c, d = c.rpartition('.')[0], c
# infer additional item properties from context
settings.infer(context)

def execute(self, parameters={}):
r'''Run a pipeline.
Expand Down
7 changes: 7 additions & 0 deletions skypy/pipeline/tests/data/bug_464.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tables:
bug_table_1:
a: !numpy.random.uniform [0, 1, 10]
bug_table_2:
.init: !astropy.table.vstack
tables: [ $bug_table_1 ]
.depends: [ bug_table_1.complete ]
16 changes: 16 additions & 0 deletions skypy/pipeline/tests/test_skypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,25 @@ def test_logging(capsys):
assert(not err)


def test_init_depends():

# Regression test for pull request #464
# Previously the .depends keyword was also being passed to functions as a
# keyword argument. This was because of an inconsistency of how the config
# file was parsed and how the .depends keyword was handled by the Pipeline
# class during execution. The .depends keyword is now handled exclusively
# by the Call class.
rrjbca marked this conversation as resolved.
Show resolved Hide resolved

# Run skypy with default verbosity and check log is empty
filename = get_pkg_data_filename('data/bug_464.yml')
output_file = 'bug_464.fits'
assert skypy.main([filename, output_file]) == 0


def teardown_module(module):

# Remove fits file generated in test_skypy
os.remove('bug_464.fits')
os.remove('empty.fits')
os.remove('logging.fits')
os.remove('test.fits')