Repository: datahq/dataflows

Issue:
0.0.51 breaks passing in named resources to Flow
I need some time to figure out what's up here and to provide you better documention (it's possible this is on my end, if so I will close this issue) but there seems to be an issue with passing in a name for a resource to `load` since 0.0.51. Instead of only using the passed in name, it creates two resources:
1. One using the passed in name, containing the correct headers, the correct types, and no rows.
2. Another using the default empty name (aka the file name), containing the correct headers, the correct rows and no types.

I'll come back to this asap to give you more details, for now I'm using v0.0.50 

Discussion:

Patch:
diff --git a/dataflows/processors/load.py b/dataflows/processors/load.py
index 648f88f..ef94ad5 100644
--- a/dataflows/processors/load.py
+++ b/dataflows/processors/load.py
@@ -182,7 +182,7 @@ class load(DataStreamProcessor):
             else:
                 path = os.path.basename(self.load_source)
                 path = os.path.splitext(path)[0]
-                descriptor = dict(path=path,
+                descriptor = dict(path=self.name or path,
                                   profile='tabular-data-resource')
                 self.resource_descriptors.append(descriptor)
                 descriptor['name'] = self.name or path


Test patch:
diff --git a/tests/test_lib.py b/tests/test_lib.py
index 13580f5..dc5acdc 100644
--- a/tests/test_lib.py
+++ b/tests/test_lib.py
@@ -530,6 +530,25 @@ def test_load_strategies():
     }
 
 
+def test_load_name_path():
+    from dataflows import load
+
+    dp, *_ = Flow(
+        load('data/beatles_age.json', name='foo'),
+        load('data/beatles_age.csv')
+    ).process()
+
+    print(dp.descriptor['resources'])
+
+    res0 = dp.resources[0]
+    res1 = dp.resources[1]
+
+    assert res0.name == 'foo'
+    assert res0.descriptor['path'] == 'foo.json'
+    assert res1.name == 'beatles_age'
+    assert res1.descriptor['path'] == 'beatles_age.csv'
+
+
 def test_load_from_package_resources():
     from dataflows import load