PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: ecmwf/earthkit-data (python)
Issue: Test test_grib_output_pl fails
### What happened?

This test fails with

 `gribapi.errors.ReadOnlyError: Value is read only` 

when trying to set `levtype=pl` on a GRIB message. This happens because since ecCodes 2.33.0 `levtype` is a readonly key.

### What are the steps to reproduce the bug?

See above

### Version

ecCodes >= 2.33.0

### Platform (OS and architecture)

all

### Relevant log output

_No response_

### Accompanying data

_No response_

### Organisation

ECMWF
Pull request description: Fix setting grib levtype test
fixes #271 

Patch:
diff --git a/earthkit/data/readers/grib/output.py b/earthkit/data/readers/grib/output.py
index 92ae513..11bcec7 100644
--- a/earthkit/data/readers/grib/output.py
+++ b/earthkit/data/readers/grib/output.py
@@ -197,6 +197,18 @@ class GribOutput:
             except ValueError:
                 metadata["shortName"] = param
 
+        # levtype is a readOnly key in ecCodes >= 2.33.0
+        levtype_remap = {
+            "pl": "isobaricInhPa",
+            "ml": "hybrid",
+            "pt": "theta",
+            "pv": "potentialVorticity",
+            "sfc": "surface",
+        }
+        if "levtype" in metadata:
+            v = metadata.pop("levtype")
+            metadata["typeOfLevel"] = levtype_remap[v]
+
     def handle_from_metadata(self, values, metadata, compulsory):
         from .codes import GribCodesHandle  # Lazy loading of eccodes
 


Test patch:
diff --git a/tests/grib/test_grib_output.py b/tests/grib/test_grib_output.py
index 1eba7fc..56b9617 100644
--- a/tests/grib/test_grib_output.py
+++ b/tests/grib/test_grib_output.py
@@ -138,14 +138,17 @@ def test_grib_output_mars_labeling():
     sys.version_info < (3, 10),
     reason="ignore_cleanup_errors requires Python 3.10 or later",
 )
-def test_grib_output_pl():
+@pytest.mark.parametrize("levtype", [{}, {"levtype": "pl"}])
+def test_grib_output_pl(levtype):
     data = np.random.random((40320,))
 
     with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as tmp:
         path = os.path.join(tmp, "a.grib")
 
         f = earthkit.data.new_grib_output(path, date=20010101)
-        f.write(data, param="t", level=850)
+        _kwargs = dict(param="t", level=850)
+        _kwargs.update(levtype)
+        f.write(data, **_kwargs)
         f.close()
 
         ds = earthkit.data.from_source("file", path)
Repository: wntrblm/nox (python)
Issue: Set environment variable when running commands
### How would this feature be useful?

Setting an environment variable in the environment of `session.run`'d commands would allow the child process to know it is being executed by nox and perhaps even what session of nox is being. Personally, I would find this useful when `session.run`ing `bash` or `code` (using nox as a development environment manager) so that I can adjust my PS1 with the name of the session I'm in.

### Describe the solution you'd like

When running any command with `session.run`, the command environment is adjusted to set the `NOX_CURRENT_SESSION` variable with the name of the current session.

### Describe alternatives you've considered

It's entirely possible to do this myself using `env` argument to `session.run`. However it is something innocuous that takes the burden off the user without considerable maintenance effort.

### Anything else?

_No response_
Pull request description: Export session name in envvar NOX_CURRENT_SESSION
Closes #636. The environment variable `NOX_CURRENT_SESSION` is populated with the name of the current session in all subcommands of that session. 

There were a couple places to place this small bit of code. Each location caused some problems with the existing tests. The current place was chosen because it intuitively makes sense to take code that the user would write at the top of their session functions and move it up into the thing that calls the session function. Let me know if you think it belongs elsewhere.

Patch:
diff --git a/nox/sessions.py b/nox/sessions.py
index d017dc8..4a66229 100644
--- a/nox/sessions.py
+++ b/nox/sessions.py
@@ -724,6 +724,7 @@ class SessionRunner:
             with cwd:
                 self._create_venv()
                 session = Session(self)
+                session.env["NOX_CURRENT_SESSION"] = session.name
                 self.func(session)
 
             # Nothing went wrong; return a success.


Test patch:
diff --git a/tests/test_sessions.py b/tests/test_sessions.py
index f753595..5f1422f 100644
--- a/tests/test_sessions.py
+++ b/tests/test_sessions.py
@@ -900,6 +900,8 @@ class TestSessionRunner:
     def make_runner_with_mock_venv(self):
         runner = self.make_runner()
         runner._create_venv = mock.Mock()
+        runner.venv = mock.create_autospec(nox.virtualenv.VirtualEnv)
+        runner.venv.env = {}
         return runner
 
     def test_execute_noop_success(self, caplog):
@@ -1017,6 +1019,23 @@ class TestSessionRunner:
 
         assert result.status == nox.sessions.Status.FAILED
 
+    def test_execute_check_env(self):
+        runner = self.make_runner_with_mock_venv()
+
+        def func(session):
+            session.run(
+                sys.executable,
+                "-c",
+                'import os; raise SystemExit(0 if os.environ["NOX_CURRENT_SESSION"] =='
+                f" {session.name!r} else 0)",
+            )
+
+        runner.func = func
+
+        result = runner.execute()
+
+        assert result
+
 
 class TestResult:
     def test_init(self):