Repository: ResearchObject/ro-crate-py
Pull request #22 (2020-10-05 08:28:18)

Fix dataset handling in crate loading
A single item was being passed to the properties arg, rather than a dictionary.


Patch:
diff --git a/rocrate/rocrate.py b/rocrate/rocrate.py
index d6dc65a..c750b90 100644
--- a/rocrate/rocrate.py
+++ b/rocrate/rocrate.py
@@ -141,9 +141,8 @@ class ROCrate():
             if 'Dataset' in entity_types:
                 dir_path = os.path.join(source, entity['@id'])
                 if os.path.exists(dir_path):
-                    instance = Dataset(
-                        self, dir_path, entity['@id'], entity.pop('@id', None)
-                    )
+                    props = {k: v for k, v in entity.items() if k != '@id'}
+                    instance = Dataset(self, dir_path, entity['@id'], props)
                 else:
                     raise Exception('Directory not found')
             self._add_data_entity(instance)


Test patch:
diff --git a/test/test-data/read_crate/examples/README.txt b/test/test-data/read_crate/examples/README.txt
new file mode 100644
index 0000000..893abfc
--- /dev/null
+++ b/test/test-data/read_crate/examples/README.txt
@@ -0,0 +1,1 @@
+Examples directory
diff --git a/test/test-data/read_crate/ro-crate-metadata.jsonld b/test/test-data/read_crate/ro-crate-metadata.jsonld
index de7e07d..9cf452e 100644
--- a/test/test-data/read_crate/ro-crate-metadata.jsonld
+++ b/test/test-data/read_crate/ro-crate-metadata.jsonld
@@ -6,14 +6,14 @@
             "@type": "CreativeWork",
             "about": {
                 "@id": "./"
+            },
+            "conformsTo": {
+                "@id": "https://w3id.org/ro/crate/1.0"
             }
         },
         {
             "@id": "./",
-            "@type": "CreativeWork",
-            "about": {
-                "@id": "./"
-            },
+            "@type": "Dataset",
             "datePublished": "2020-06-25 17:03:04.098286",
             "hasPart": [
                 {
@@ -27,6 +27,9 @@
                 },
                 {
                     "@id": "https://raw.githubusercontent.com/ResearchObject/ro-crate-py/master/test/test-data/sample_file.txt"
+                },
+                {
+                    "@id": "examples/"
                 }
             ],
             "mainEntity": {
@@ -42,11 +45,25 @@
         },
         {
             "@id": "test_galaxy_wf.ga",
-            "@type": ["File","Workflow"]
+            "@type": [
+                "File",
+                "Workflow",
+                "SoftwareSourceCode"
+            ],
+            "programmingLanguage": {
+                "@id": "https://galaxyproject.org"
+            },
+            "subjectOf": {
+                "@id": "abstract_wf.cwl"
+            }
         },
         {
             "@id": "abstract_wf.cwl",
-            "@type": "File"
+            "@type": [
+                "File",
+                "SoftwareSourceCode",
+                "Workflow"
+            ]
         },
         {
             "@id": "test_file_galaxy.txt",
@@ -60,7 +77,10 @@
         {
             "@id": "https://raw.githubusercontent.com/ResearchObject/ro-crate-py/master/test/test-data/sample_file.txt",
             "@type": "File"
+        },
+        {
+            "@id": "examples/",
+            "@type": "Dataset"
         }
-
     ]
 }