nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: IAMconsortium/pyam
Pull request #359 (2020-04-06 15:10:58)

Rename filter payload attribute to timeslices
- add logging to filter elements counts

# Please confirm that this PR has done the following:

- [ ] Tests Added
- [ ] Documentation Added
- [ ] Description in RELEASE_NOTES.md Added

## Adding to RELEASE_NOTES.md (remove section after adding to RELEASE_NOTES.md)

Please add a single line in the release notes similar to the following:

```
- (#XX)[http://link-to-pr.com] Added feature which does something
```

# Description of PR

Please describe the changes introduced by this PR.


coveralls: 
[![Coverage Status](https://coveralls.io/builds/30623260/badge)](https://coveralls.io/builds/30623260)

Coverage increased (+0.007%) to 86.243% when pulling **4717dc2cedd05f5ef6b0b941642fe6ce42fd65d9 on feature/update-ixmp-api-calls** into **063875bdb73f270d37b829c4c58ac7ec4e17ac53 on master**.


Patch:
diff --git a/pyam/iiasa.py b/pyam/iiasa.py
index a371cbc..699f147 100644
--- a/pyam/iiasa.py
+++ b/pyam/iiasa.py
@@ -330,7 +330,8 @@ class Connection(object):
         # pass empty list to API if all regions selected
         if len(regions) == len(self.regions()):
             regions = []
-
+        logger.debug(f"Prepared filter for {len(regions)} region(s), "
+                     f"{len(variables)} variables and {len(runs)} runs")
         data = {
             "filters": {
                 "regions": list(regions),
@@ -338,7 +339,7 @@ class Connection(object):
                 "runs": list(runs),
                 "years": [],
                 "units": [],
-                "times": []
+                "timeslices": []
             }
         }
         return data


Test patch:
diff --git a/tests/test_iiasa.py b/tests/test_iiasa.py
index 7335846..0c74639 100644
--- a/tests/test_iiasa.py
+++ b/tests/test_iiasa.py
@@ -140,10 +140,8 @@ QUERY_DATA_EXP = {
         "runs": [],
         "years": [],
         "units": [],
-        "times": []
+        "timeslices": []
     }
-
-
 }
Repository: streamich/memfs
Pull request #59 (2018-01-09 13:41:47)

fix: fs.open on directory as read-only
Fixes https://github.com/streamich/memfs/issues/58


Patch:
diff --git a/src/volume.ts b/src/volume.ts
index afe93021..76db1fc5 100644
--- a/src/volume.ts
+++ b/src/volume.ts
@@ -844,7 +844,7 @@ export class Volume {
         if(!realLink) throwError(ENOENT, 'open', link.getPath());
 
         const node = realLink.getNode();
-        if(node.isDirectory())
+        if(node.isDirectory() && (flagsNum !== FLAGS.r))
             throwError(EISDIR, 'open', link.getPath());
 
         // Check node permissions


Test patch:
diff --git a/src/__tests__/volume.test.ts b/src/__tests__/volume.test.ts
index 623028fd..f42f04f1 100644
--- a/src/__tests__/volume.test.ts
+++ b/src/__tests__/volume.test.ts
@@ -277,6 +277,7 @@ describe('volume', () => {
         });
         describe('.open(path, flags[, mode], callback)', () => {
             const vol = new Volume;
+            vol.mkdirSync('/test-dir');
             it('Create new file at root (/test.txt)', done => {
                 vol.open('/test.txt', 'w', (err, fd) => {
                     expect(err).toBe(null);
@@ -338,7 +339,20 @@ describe('volume', () => {
                   expect(vol.root.getChild('b.txt').getNode().canWrite()).toBe(true);
                   done();
               });
-            })
+            });
+            it('Error on incorrect flags for directory', done => {
+                vol.open('/test-dir', 'r+', (err, fd) => {
+                    expect(err.code).toBe('EISDIR');
+                    done();
+                });
+            });
+            it('Properly opens directory as read-only', done => {
+                vol.open('/test-dir', 'r', (err, fd) => {
+                    expect(err).toBe(null);
+                    expect(typeof fd).toBe('number');
+                    done();
+                });
+            });
         });
         describe('.close(fd, callback)', () => {
             const vol = new Volume;
Repository: streamich/memfs
Pull request #378 (2019-05-18 14:14:40)

feat: allow exporting file paths in Volume.toJSON
This allows files path to be specified in `Volume.toJSON`. Without this patch, files specificed would show up in the resulting `JSON`, but with its contets set to `null`.

Test is included.


Patch:
diff --git a/src/volume.ts b/src/volume.ts
index 3c377c5f..7ae3fcf4 100644
--- a/src/volume.ts
+++ b/src/volume.ts
@@ -809,7 +809,14 @@ export class Volume {
   private _toJSON(link = this.root, json = {}, path?: string) {
     let isEmpty = true;
 
-    for (const name in link.children) {
+    let children = link.children;
+
+    if (link.getNode().isFile()) {
+      children = { [link.getName()]: link.parent.getChild(link.getName()) };
+      link = link.parent;
+    }
+
+    for (const name in children) {
       isEmpty = false;
 
       const child = link.getChild(name);


Test patch:
diff --git a/src/__tests__/volume.test.ts b/src/__tests__/volume.test.ts
index 4f5f473c..bc76b592 100644
--- a/src/__tests__/volume.test.ts
+++ b/src/__tests__/volume.test.ts
@@ -130,6 +130,18 @@ describe('volume', () => {
         });
       });
 
+      it('Specify a file export path', () => {
+        const vol = Volume.fromJSON({
+          '/foo': 'bar',
+          '/dir/a': 'b',
+          '/dir2/a': 'b',
+          '/dir2/c': 'd',
+        });
+        expect(vol.toJSON(['/dir/a'])).toEqual({
+          '/dir/a': 'b',
+        });
+      });
+
       it('Accumulate exports on supplied object', () => {
         const vol = Volume.fromJSON({
           '/foo': 'bar',
Repository: streamich/memfs
Pull request #1041 (2024-07-01 14:50:45)

fix: ensure files in subdirectories are returned as buffers when calling `toJSON` with `asBuffer`
Without that, `asBuffer` only works for files at the root of the volume, not those in sub-directories.


Patch:
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 00000000..a5497b62
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,13 @@
+# Security Policy
+
+## Supported Versions
+
+We release patches for security vulnerabilities. The latest major version
+will support security patches.
+
+## Reporting a Vulnerability
+
+Please report (suspected) security vulnerabilities to
+**[streamich@gmail.com](mailto:streamich@gmail.com)**. We will try to respond
+within 48 hours. If the issue is confirmed, we will release a patch as soon
+as possible depending on complexity.
diff --git a/src/volume.ts b/src/volume.ts
index 32ff2c99..ac5e0ccc 100644
--- a/src/volume.ts
+++ b/src/volume.ts
@@ -554,7 +554,7 @@ export class Volume implements FsCallbackApi, FsSynchronousApi {
         if (path) filename = relative(path, filename);
         json[filename] = asBuffer ? node.getBuffer() : node.getString();
       } else if (node.isDirectory()) {
-        this._toJSON(child, json, path);
+        this._toJSON(child, json, path, asBuffer);
       }
     }
 


Test patch:
diff --git a/src/__tests__/volume.test.ts b/src/__tests__/volume.test.ts
index d1181ab2..a8b1ffb3 100644
--- a/src/__tests__/volume.test.ts
+++ b/src/__tests__/volume.test.ts
@@ -196,6 +196,15 @@ describe('volume', () => {
         const result = vol.toJSON('/', {}, false, true)['/file'];
         expect(result).toStrictEqual(buffer);
       });
+
+      it('Outputs files in subdirectories as buffers too', () => {
+        const buffer = Buffer.from('Hello');
+        const vol = new Volume();
+        vol.mkdirSync('/dir');
+        vol.writeFileSync('/dir/file', buffer);
+        const result = vol.toJSON('/', {}, false, true)['/dir/file'];
+        expect(result).toStrictEqual(buffer);
+      });
     });
 
     describe('.fromJSON(json[, cwd])', () => {
Repository: streamich/memfs
Pull request #1085 (2025-01-09 17:50:12)

feat: allow setting rdev on node
This adds it to stat too, so rdev will propagate.


kylecarbs: True. Will change.
kylecarbs: @G-Rath this gets a bit awkward because it would be made with the `mknod` syscall, which is unavailable in NodeJS.

I can add a test inside of `Node` at least. I'm just using it internally anyways, so that works.
kylecarbs: @G-Rath I added a test to `statSync` which seemed like the best spot.
kylecarbs: @G-Rath fixed the prettier issue!

Patch:
diff --git a/src/Stats.ts b/src/Stats.ts
index 48745203..75a6b923 100644
--- a/src/Stats.ts
+++ b/src/Stats.ts
@@ -25,7 +25,7 @@ export class Stats<T = TStatNumber> {
     stats.uid = getStatNumber(uid);
     stats.gid = getStatNumber(gid);
 
-    stats.rdev = getStatNumber(0);
+    stats.rdev = getStatNumber(node.rdev);
     stats.blksize = getStatNumber(4096);
     stats.ino = getStatNumber(node.ino);
     stats.size = getStatNumber(node.getSize());
diff --git a/src/node.ts b/src/node.ts
index 8152f747..d53cdacd 100644
--- a/src/node.ts
+++ b/src/node.ts
@@ -28,6 +28,7 @@ export class Node extends EventEmitter {
 
   // data: string = '';
   buf: Buffer;
+  rdev: number = 0;
 
   mode: number; // S_IFDIR, S_IFREG, etc..
 


Test patch:
diff --git a/src/__tests__/volume/statSync.test.ts b/src/__tests__/volume/statSync.test.ts
index c7881998..391d5cdd 100644
--- a/src/__tests__/volume/statSync.test.ts
+++ b/src/__tests__/volume/statSync.test.ts
@@ -12,6 +12,14 @@ describe('.statSync(...)', () => {
     expect(stats.size).toBe(11);
   });
 
+  it('returns rdev', () => {
+    const vol = create({});
+    const fd = vol.openSync('/null', 'w');
+    vol.fds[fd].node.rdev = 1;
+    const stats = vol.statSync('/null');
+    expect(stats.rdev).toBe(1);
+  });
+
   it('returns undefined for non-existent targets with the throwIfNoEntry option set to false', () => {
     const vol = create({});
Repository: streamich/memfs
Pull request #516 (2020-03-12 11:21:26)

fix: should throw `EEXIST` instead of `EISDIR` on `mkdirSync('/')`
The `EISDIR` implementation is considered a bug in BSD operating
systems.

See the bug report at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=59739
and the POSIX specification at https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html


Patch:
diff --git a/src/volume.ts b/src/volume.ts
index 73552fd7..8849d71c 100644
--- a/src/volume.ts
+++ b/src/volume.ts
@@ -1812,7 +1812,7 @@ export class Volume {
 
     // This will throw if user tries to create root dir `fs.mkdirSync('/')`.
     if (!steps.length) {
-      throw createError(EISDIR, 'mkdir', filename);
+      throw createError(EEXIST, 'mkdir', filename);
     }
 
     const dir = this.getLinkParentAsDirOrThrow(filename, 'mkdir');


Test patch:
diff --git a/src/__tests__/volume/__snapshots__/mkdirSync.test.ts.snap b/src/__tests__/volume/__snapshots__/mkdirSync.test.ts.snap
index 976964a4..d91328f6 100644
--- a/src/__tests__/volume/__snapshots__/mkdirSync.test.ts.snap
+++ b/src/__tests__/volume/__snapshots__/mkdirSync.test.ts.snap
@@ -1,5 +1,5 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
-exports[`mkdirSync throws when creating root directory 1`] = `"EISDIR: illegal operation on a directory, mkdir '/'"`;
+exports[`mkdirSync throws when creating root directory 1`] = `"EEXIST: file already exists, mkdir '/'"`;
 
 exports[`mkdirSync throws when re-creating existing directory 1`] = `"EEXIST: file already exists, mkdir '/new-dir'"`;
Repository: streamich/memfs
Pull request #907 (2023-06-02 23:08:37)

fix: correctly output filename when watching files
This addresses "enough" of the errors described [here](https://github.com/streamich/memfs/pull/902#issuecomment-1574385481), and which are currently causing the test suite for `unionfs` to fail when using the latest version of `memfs`.

I say "enough" because my testing indicates that the current implementation is still not 1:1 with native `fs`, and I wouldn't be surprised if this change doesn't work in all cases, but it does make is closer to native `fs` 🤷 


Patch:
diff --git a/src/volume.ts b/src/volume.ts
index 9282003a..78d7726a 100644
--- a/src/volume.ts
+++ b/src/volume.ts
@@ -2759,7 +2759,15 @@ export class FSWatcher extends EventEmitter {
     const watchLinkNodeChanged = (link: Link) => {
       const filepath = link.getPath();
       const node = link.getNode();
-      const onNodeChange = () => this.emit('change', 'change', relative(this._filename, filepath));
+      const onNodeChange = () => {
+        let filename = relative(this._filename, filepath);
+
+        if (!filename) {
+          filename = this._getName();
+        }
+
+        return this.emit('change', 'change', filename);
+      };
       node.on('change', onNodeChange);
 
       const removers = this._listenerRemovers.get(node.ino) ?? [];


Test patch:
diff --git a/src/__tests__/volume.test.ts b/src/__tests__/volume.test.ts
index 9aea5c26..31a905f4 100644
--- a/src/__tests__/volume.test.ts
+++ b/src/__tests__/volume.test.ts
@@ -1090,6 +1090,42 @@ describe('volume', () => {
       });
     });
     describe('.watch(path[, options], listener)', () => {
+      it('should handle watching a file correctly', () => {
+        const vol = Volume.fromJSON({ '/tmp/foo.js': 'hello test' });
+        vol.writeFileSync('/tmp/foo.js', 'hello test');
+
+        const mockCallback = jest.fn();
+        const writtenContent = 'hello world';
+        const watcher = vol.watch('/tmp/foo.js', mockCallback as any);
+
+        try {
+          vol.writeFileSync('/tmp/foo.js', writtenContent);
+
+          expect(mockCallback).toBeCalledTimes(2);
+          expect(mockCallback).toBeCalledWith('change', 'foo.js');
+        } finally {
+          watcher.close();
+        }
+      });
+
+      it('should handle watching a directory correctly', () => {
+        const vol = Volume.fromJSON({ '/tmp/foo.js': 'hello test' });
+        vol.mkdirSync('/tmp/foo-dir');
+
+        const mockCallback = jest.fn();
+        const writtenContent = 'hello world';
+        const watcher = vol.watch('/tmp/foo-dir', mockCallback as any);
+
+        try {
+          vol.writeFileSync('/tmp/foo-dir/foo.js', writtenContent);
+
+          expect(mockCallback).toBeCalledTimes(1);
+          expect(mockCallback).toBeCalledWith('rename', 'foo.js');
+        } finally {
+          watcher.close();
+        }
+      });
+
       it('Calls listener on .watch when renaming with recursive=true', done => {
         const vol = new Volume();
         vol.mkdirSync('/test');