Repository: rs-station/careless (language: python)

Issue:
update workflow versions
Update the versions of actions in build and publish workflows.


Discussion / hints:
## [Codecov](https://app.codecov.io/gh/rs-station/careless/pull/139?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=rs-station) Report
> Merging [#139](https://app.codecov.io/gh/rs-station/careless/pull/139?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=rs-station) (c469268) into [main](https://app.codecov.io/gh/rs-station/careless/commit/42f8c9615dc7010494c685cdadaa94fa1ce5ef39?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=rs-station) (42f8c96) will **decrease** coverage by `9.39%`.
> The diff coverage is `n/a`.

```diff
@@            Coverage Diff             @@
##             main     #139      +/-   ##
==========================================
- Coverage   79.18%   69.79%   -9.39%     
==========================================
  Files          52       52              
  Lines        2344     2344              
==========================================
- Hits         1856     1636     -220     
- Misses        488      708     +220     
```

| [Flag](https://app.codecov.io/gh/rs-station/careless/pull/139/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=rs-station) | Coverage Δ | |
|---|---|---|
| [unittests](https://app.codecov.io/gh/rs-station/careless/pull/139/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=rs-station) | `69.79% <ø> (-9.39%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=rs-station#carryforward-flags-in-the-pull-request-comment) to find out more.

[see 6 files with indirect coverage changes](https://app.codecov.io/gh/rs-station/careless/pull/139/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=rs-station)

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=rs-station)

CI was failing as of the tensorflow 2.14 release. The underlying cause was a memory leak in the `test_cli.py` submodule. Tracing this back, it seems to be an inherent issue with tensorflow a la this [issue](https://github.com/tensorflow/tensorflow/issues/36465). This issue was always present, but it didn't become a problem until 2.14 started to allocate more memory than previous versions. Running careless in a separate process for the purposes of testing bypasses the memory leak and forces tf to clean up after the process exits. So, from now on, I'll be using subprocess to call the CLI during testing. It's not the most satisfying solution and will probably make debugging harder by dint of less specific error messages. However, it is required to stop the memory leak in order to stay within the ram limits of github's default runner. 

Fix patch:
diff --git a/.coveragerc b/.coveragerc
index bc462d9..58140ff 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -1,2 +1,3 @@
 [run]
 source = careless 
+concurrency = multiprocessing


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 2290ce7..7e5781b 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1,10 +1,26 @@
 import pytest
 import reciprocalspaceship as rs
 from tempfile import TemporaryDirectory
-from careless.careless import run_careless
+from careless.careless import run_careless as _run_careless
 from os.path import exists
+import multiprocessing
 
 niter = 10
+# True will use multiprocessing to bypass the tf memory leak issue,
+# but it may result in less verbose error messages.
+use_mp = True
+
+def run_careless(parser):
+    """
+    Workaround for tensorflow memory leak.
+    see: https://github.com/tensorflow/tensorflow/issues/36465
+    """
+    if use_mp:
+        proc = multiprocessing.Process(target=_run_careless, args=(parser,))
+        proc.start()
+        proc.join()
+    else:
+        _run_careless(parser)
 
 def base_test_separate(flags, filenames):
     with TemporaryDirectory() as td:
@@ -70,7 +86,7 @@ def test_twofile(off_file, on_file, on_file_alt_sg, ev11, dmin, anomalous, isigi
         base_test_together(flags, [off_file, on_file])
 
 def test_crystfel(stream_file):
-    flags = f"mono --iterations={niter} --spacegroups=1 dHKL,image_id"
+    flags = f"mono --disable-gpu --iterations={niter} --spacegroups=1 dHKL,image_id"
     base_test_together(flags, [stream_file])
 
 def test_scale_weight_save_and_load(off_file):