Skip to content

Commit 1f9d0fc

Browse files
committed
BUG: Move handling of context arguments after handling of .depends keyword (#465)
1 parent aa95dec commit 1f9d0fc

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

skypy/pipeline/_pipeline.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ def __init__(self, configuration):
101101
self.dag.add_node(job, skip=False)
102102
if isinstance(settings, Item):
103103
items[job] = settings
104-
# infer additional item properties from context
105-
settings.infer(context)
106104
for table, columns in self.table_config.items():
107105
table_complete = '.'.join((table, 'complete'))
108106
self.dag.add_node(table_complete)
@@ -114,8 +112,6 @@ def __init__(self, configuration):
114112
self.dag.add_edge(job, table_complete)
115113
if isinstance(settings, Item):
116114
items[job] = settings
117-
# infer additional item properties from context
118-
settings.infer(context)
119115
# DAG nodes for individual columns in multi-column assignment
120116
names = [n.strip() for n in column.split(',')]
121117
if len(names) > 1:
@@ -137,6 +133,8 @@ def __init__(self, configuration):
137133
while c:
138134
self.dag.add_edge(c, d)
139135
c, d = c.rpartition('.')[0], c
136+
# infer additional item properties from context
137+
settings.infer(context)
140138

141139
def execute(self, parameters={}):
142140
r'''Run a pipeline.

skypy/pipeline/tests/test_pipeline.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from astropy.cosmology import FlatLambdaCDM, default_cosmology
22
from astropy.cosmology.core import Cosmology
33
from astropy.io import fits
4-
from astropy.table import Table
4+
from astropy.table import Table, vstack
55
from astropy.table.column import Column
66
from astropy.units import Quantity
77
from astropy.utils.data import get_pkg_data_filename
@@ -237,6 +237,28 @@ def value_in_cm(q):
237237
np.testing.assert_array_less(pipeline['test_table.lengths_in_cm'], 100)
238238

239239

240+
def test_depends():
241+
242+
# Regression test for GitHub Issue #464
243+
# Previously the .depends keyword was also being passed to functions as a
244+
# keyword argument. This was because Pipeline was executing Item.infer to
245+
# handle additional function arguments from context before handling
246+
# additional dependencies specified using the .depends keyword. The
247+
# .depends keyword is now handled first.
248+
249+
config = {'tables': {
250+
'table_1': {
251+
'column1': Call(np.random.uniform, [0, 1, 10])},
252+
'table_2': {
253+
'.init': Call(vstack, [], {
254+
'tables': [Ref('table_1')],
255+
'.depends': ['table_1.complete']})}}}
256+
257+
pipeline = Pipeline(config)
258+
pipeline.execute()
259+
assert np.all(pipeline['table_1'] == pipeline['table_2'])
260+
261+
240262
def teardown_module(module):
241263

242264
# Remove fits file generated in test_pipeline

0 commit comments

Comments
 (0)