PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: ResearchObject/ro-crate-py (python)
Issue: Adding a directory to a new crate gives an error when trying to write the crate: AttributeError: 'str' object has no attribute 'exists'
Adding a directory to a new crate gives an error when trying to write the crate: `AttributeError: 'str' object has no attribute 'exists'`

See the below example:

```python
import os
from rocrate.rocrate import ROCrate
crate = ROCrate()
os.makedirs("tmp3", exist_ok=True)
dataset_entity = crate.add_directory(source="tmp3", dest_path="new_tmp")
crate.write("./new_crate4")
```

```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_9363/134362041.py in <module>
      4 open('tmp3/empty_file', 'w').close()
      5 dataset_entity = crate.add_directory(source="tmp", dest_path="new_tmp")
----> 6 crate.write("./new_crate3")

~/Downloads/Elixir/ro-crate-py/rocrate/rocrate.py in write(self, base_path)
    473             self._copy_unlisted(self.source, base_path)
    474         for writable_entity in self.data_entities + self.default_entities:
--> 475             writable_entity.write(base_path)
    476 
    477     write_crate = write  # backwards compatibility

~/Downloads/Elixir/ro-crate-py/rocrate/model/dataset.py in write(self, base_path)
     49         else:
     50             out_path.mkdir(parents=True, exist_ok=True)
---> 51             if not self.crate.source and self.source and self.source.exists():
     52                 self.crate._copy_unlisted(self.source, out_path)
     53 

AttributeError: 'str' object has no attribute 'exists'
```
Pull request description: Fix dataset writing when source is a string
Fixes #90.

Patch:
diff --git a/rocrate/model/dataset.py b/rocrate/model/dataset.py
index 15489b5..4746e9a 100644
--- a/rocrate/model/dataset.py
+++ b/rocrate/model/dataset.py
@@ -48,7 +48,7 @@ class Dataset(FileOrDir):
                 self.__get_parts(out_path)
         else:
             out_path.mkdir(parents=True, exist_ok=True)
-            if not self.crate.source and self.source and self.source.exists():
+            if not self.crate.source and self.source and Path(self.source).exists():
                 self.crate._copy_unlisted(self.source, out_path)
 
     def __get_parts(self, out_path):


Test patch:
diff --git a/test/test_write.py b/test/test_write.py
index 675bebd..c1273f5 100644
--- a/test/test_write.py
+++ b/test/test_write.py
@@ -265,6 +265,8 @@ def test_dataset(test_data_dir, tmpdir):
     assert crate.dereference("b") is d1
     d2 = crate.add_dataset(path, "a/b")
     assert crate.dereference("a/b") is d2
+    d_from_str = crate.add_dataset(str(test_data_dir / "c"))
+    assert crate.dereference("c") is d_from_str
 
     out_path = tmpdir / 'ro_crate_out'
     out_path.mkdir()
@@ -272,6 +274,7 @@ def test_dataset(test_data_dir, tmpdir):
 
     assert (out_path / "b").is_dir()
     assert (out_path / "a" / "b").is_dir()
+    assert (out_path / "c").is_dir()
 
 
 def test_no_parts(tmpdir, helpers):