Factual / drake

Data workflow tool, like a "Make for data"
Other
1.48k stars 110 forks source link

Feature/inherit context #211

Closed chen-factual closed 8 years ago

chen-factual commented 8 years ago

Nested includes within files included via %context use relative paths. #204

E.g.

foo.d

%context nested/bar.d

nested/bar.d

%include baz.d

Now bar.d looks in the nested/ folder for baz.d instead of the top level folder.

potash commented 8 years ago

@chen-factual, I think this might not be working as intended. Here is an example.

in a/Drakefile:

%include dir/Drakefile

In a/dir/Drakefile2:

%include Drakefile3

In a/Drakefile3

a <-
   touch $OUTPUT

This workflow works. Notice that a/dir/Drakefile2's include is relative to the a/Drakefile context.

Now if I try to %context this workflow in a file b/Drakefile:

%context ../a/Drakefile

I get

java.io.FileNotFoundException: b/./Drakefile3 (No such file or directory)

In other words Drakefile2 seems to be run from the b/Drakefile context, not from the a/Drakefile context as desired.

chen-factual commented 8 years ago

Hey @potash, thanks for filing this.

The problem here is your a/Drakefile: it should %context dir/Drakefile2 instead of %include dir/Drakefile2. Here's why:

So to summarize, here's what I have:

a/Drakefile:

%context dir/Drakefile2

a/dir/Drakefile2:

%include Drakefile3

a/dir/Drakefile3:

a <-
  touch $OUTPUT

b/Drakefile:

%context ../a/Drakefile

Hope that helps, please let me know if you run into more problems.

potash commented 8 years ago

@chen-factual thanks for the quick reply. Actually in my example Drakefile3 really does live in a/not a/dir. running drake in a/ works fine. It only fails when I run drake from b/.

I think the problem is that after the %context ../a/Drakefile BASE is set to a/ but after the %include dir/Drakefile2 BASE gets reset back to b/. That seems wrong?

chen-factual commented 8 years ago

Ah I see, the context is applied to a/Drakefile, but it doesn't propagate further down.

Yeah this should be a bug. I'll file a ticket and tag you on it, thanks for the report.