PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: sharkdp/numbat (rust)

Issue:
Add heat energy units therm and thermie

https://en.wikipedia.org/wiki/Therm
https://en.wikipedia.org/wiki/Thermie

Pull request:
Add new heat energy units
Closes #471

Patch:
diff --git a/book/src/list-units.md b/book/src/list-units.md
index 4e3d8fd..a33cce1 100644
--- a/book/src/list-units.md
+++ b/book/src/list-units.md
@@ -47,6 +47,8 @@ and — where sensible — units allow for [binary prefixes](https://en.wikipedi
 | `Energy` | [Joule](https://en.wikipedia.org/wiki/Joule) | `J`, `joule`, `joules` |
 | `Energy` | [Planck energy](https://en.wikipedia.org/wiki/Planck_energy) | `planck_energy` |
 | `Energy` | [Rydberg unit of energy](https://en.wikipedia.org/wiki/Rydberg_constant) | `Ry` |
+| `Energy` | [Therm](https://en.wikipedia.org/wiki/Therm) | `therm`, `therms` |
+| `Energy` | [Thermie](https://en.wikipedia.org/wiki/Thermie) | `thermie`, `thermies` |
 | `Energy` | [Watt-hour](https://en.wikipedia.org/wiki/Watt_hour) | `watthour`, `Wh` |
 | `EquivalentDose` | [Sievert](https://en.wikipedia.org/wiki/Sievert) | `sievert`, `sieverts`, `Sv` |
 | `Force` | [Dyne](https://en.wikipedia.org/wiki/Dyne) | `dyn`, `dyne` |
diff --git a/numbat/modules/units/misc.nbt b/numbat/modules/units/misc.nbt
index 34cca9c..2920c25 100644
--- a/numbat/modules/units/misc.nbt
+++ b/numbat/modules/units/misc.nbt
@@ -30,6 +30,17 @@ unit calorie: Energy = 4.184 joule
 @aliases(Btu)
 unit BTU: Energy = 1055.05585262 joule
 
+@name("Therm")
+@description("A non-SI metric unit of heat energy. This is the ISO definition, also called Therm (EC).")
+@url("https://en.wikipedia.org/wiki/Therm")
+@aliases(therms)
+unit therm: Energy = 100_000 BTU
+
+@name("Thermie")
+@url("https://en.wikipedia.org/wiki/Thermie")
+@aliases(thermies)
+unit thermie: Energy = 1000 kcal
+
 @name("Pound-force")
 @url("https://en.wikipedia.org/wiki/Pound_(force)")
 @aliases(lbf: short)


Test patch:
diff --git a/examples/tests/unit_consistency_misc.nbt b/examples/tests/unit_consistency_misc.nbt
index 70d16f3..019f10b 100644
--- a/examples/tests/unit_consistency_misc.nbt
+++ b/examples/tests/unit_consistency_misc.nbt
@@ -62,6 +62,8 @@ assert_eq(8e-15, 8 ppq, 1e-16)
 
 assert_eq(1 calorie, 4.184 J)
 assert_eq(1 BTU, 1055.05585262 J)
+assert_eq(1 therm, 1.05505585262e8 J)
+assert_eq(1 thermie, 4.184e6 J)
 assert_eq(1 lbf, 4.448222 N)
 assert_eq(1 ozf, (4.448222 / 16.0) N, 1e-5 N)
 assert_eq(60 RPM, 1 Hz)
Repository: nats-io/nats-server (go)

Issue:
Stream delete can fail for non empty directory
During concurrent consumer create/delete and stream create/delete it can happen that a stream directory during delete is not empty 

```
stream delete failed: unlinkat /var/folders/2p/lsd279293x7618xcjfl2bc380000gn/T/jstest632941891/jetstream/$G/streams/ELECTION: directory not empty (10050)
```

Pull request:
[FIXED] #2417
Signed-off-by: Derek Collison <derek@nats.io>

Resolves #2417 

/cc @nats-io/core


Patch:
diff --git a/server/filestore.go b/server/filestore.go
index 30f04d87..4d4d3331 100644
--- a/server/filestore.go
+++ b/server/filestore.go
@@ -4145,7 +4145,19 @@ func (fs *fileStore) Delete() error {
 	if err := fs.Stop(); err != nil {
 		return err
 	}
-	return os.RemoveAll(fs.fcfg.StoreDir)
+
+	err := os.RemoveAll(fs.fcfg.StoreDir)
+	if err == nil {
+		return nil
+	}
+	ttl := time.Now().Add(time.Second)
+	for time.Now().Before(ttl) {
+		time.Sleep(10 * time.Millisecond)
+		if err = os.RemoveAll(fs.fcfg.StoreDir); err == nil {
+			return nil
+		}
+	}
+	return err
 }
 
 // Lock should be held.


Test patch:
diff --git a/server/filestore_test.go b/server/filestore_test.go
index 5a59506f..79d2760a 100644
--- a/server/filestore_test.go
+++ b/server/filestore_test.go
@@ -2675,6 +2675,41 @@ func TestFileStoreStreamStateDeleted(t *testing.T) {
 	}
 }
 
+// We have reports that sometimes under load a stream could complain about a storage directory
+// not being empty.
+func TestFileStoreStreamDeleteDirNotEmpty(t *testing.T) {
+	storeDir := createDir(t, JetStreamStoreDir)
+	defer removeDir(t, storeDir)
+
+	fs, err := newFileStore(FileStoreConfig{StoreDir: storeDir}, StreamConfig{Name: "zzz", Storage: FileStorage})
+	if err != nil {
+		t.Fatalf("Unexpected error: %v", err)
+	}
+	defer fs.Stop()
+
+	subj, toStore := "foo", uint64(10)
+	for i := uint64(1); i <= toStore; i++ {
+		msg := []byte(fmt.Sprintf("[%08d] Hello World!", i))
+		if _, _, err := fs.StoreMsg(subj, nil, msg); err != nil {
+			t.Fatalf("Error storing msg: %v", err)
+		}
+	}
+
+	ready := make(chan bool)
+	go func() {
+		g := path.Join(storeDir, "g")
+		ready <- true
+		for i := 0; i < 100; i++ {
+			ioutil.WriteFile(g, []byte("OK"), defaultFilePerms)
+		}
+	}()
+
+	<-ready
+	if err := fs.Delete(); err != nil {
+		t.Fatalf("Delete returned an error: %v", err)
+	}
+}
+
 func TestFileStoreConsumerPerf(t *testing.T) {
 	// Comment out to run, holding place for now.
 	t.SkipNow()
Repository: getmoto/moto (python)

Issue:
StateTransitionReason has no value after stopping an instance
Hi All,

I am struggling with getting moto 5.0.3 test run correctly. I have a code that reads StateTransitionReason date and makes calculations to find the difference. However, after stopping instance with moto:

```
    reservation = ec2.create_instances(
        ImageId=EXAMPLE_AMI_ID, 
        MinCount=1, 
        MaxCount=1,
        TagSpecifications=[
            {
                "ResourceType": "instance",
                "Tags": ec2_tags,
            }
        ]
    )

    # stop instances
    reservation[0].stop()
```

Field for the StateTransitionReason turns empty.

```
'State': {'Code': 80, 'Name': 'stopped'}, 
'StateTransitionReason': '', 
'SubnetId': 'subnet-b4e251ec'
```

I am expecting to see similar result to documentation. 

`'StateTransitionReason': 'User initiated (2019-04-08 14:29:07 UTC)',`

Thank you for your help in advance...




Pull request:
Add StateTransitionReason to ec2:DescribeInstances response
Closes #7486 

Patch:
diff --git a/moto/ec2/responses/instances.py b/moto/ec2/responses/instances.py
index 479cc3edb..78b1ccfc9 100644
--- a/moto/ec2/responses/instances.py
+++ b/moto/ec2/responses/instances.py
@@ -463,7 +463,7 @@ INSTANCE_TEMPLATE = """<item>
           <privateDnsName>{{ instance.private_dns }}</privateDnsName>
           <publicDnsName>{{ instance.public_dns }}</publicDnsName>
           <dnsName>{{ instance.public_dns }}</dnsName>
-          <reason/>
+          <reason>{{ instance._reason }}</reason>
           {% if instance.key_name is not none %}
              <keyName>{{ instance.key_name }}</keyName>
           {% endif %}


Test patch:
diff --git a/tests/test_ec2/test_instances.py b/tests/test_ec2/test_instances.py
index 161938d7b..7cd80dcbb 100644
--- a/tests/test_ec2/test_instances.py
+++ b/tests/test_ec2/test_instances.py
@@ -973,6 +973,7 @@ def test_instance_start_and_stop():
 
     instance1.reload()
     assert instance1.state == {"Code": 80, "Name": "stopped"}
+    assert instance1.state_transition_reason.startswith("User initiated")
 
     with pytest.raises(ClientError) as ex:
         client.start_instances(InstanceIds=[instance1.id], DryRun=True)