devitocodes / pyrevolve

Python library to manage checkpointing for adjoints
Eclipse Public License 1.0
15 stars 6 forks source link

pyrevolve depends on a GPL library #61

Open mmohrhard opened 1 year ago

mmohrhard commented 1 year ago

Hey,

I think that right now, pyrevolve brings in a GPL dependency in the form of contexttimer (https://pypi.org/project/contexttimer/)

Currently, the contexttimer objects are used, but the results are discarded after computation. The easiest fix would be to just get rid of the dependency and the corresponding code. However, if the corresponding feature is meant to be used in the future, it would be easy enough to reimplement that piece of code in pyrevolve with contextlib and timer directly.

mmohrhard commented 1 year ago

The following patch is the one that I use for our internal builds:

From e8d297e4e948129d2ee06497c1175852cad57eb9 Mon Sep 17 00:00:00 2001
From: Markus Mohrhard <markusm@dug.com>
Date: Sat, 10 Jun 2023 22:15:26 +0800
Subject: [PATCH] remove GPL dependency

---
 pyrevolve/compression.py | 6 +-----
 setup.py                 | 2 +-
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/pyrevolve/compression.py b/pyrevolve/compression.py
index 915db5c..f8569cb 100644
--- a/pyrevolve/compression.py
+++ b/pyrevolve/compression.py
@@ -1,5 +1,4 @@
 import numpy as np
-from contexttimer import Timer
 from functools import partial
 import pickle

@@ -69,15 +68,12 @@ def blosc_compress(params, indata):
     s = indata.tostring()
     chunk_size = params.get('chunk_size')
     chunked = [s[i:i+chunk_size] for i in range(0, len(s), chunk_size)]
-    time = 0
     size = 0
     compressed = bytes()
     chunk_sizes = []
     for chunk in chunked:
-        with Timer(factor=1000) as t:
-            c = blosc.compress(chunk)
+        c = blosc.compress(chunk)
         compressed += c
-        time += t.elapsed
         size += len(c)
         chunk_sizes.append(len(c))
     metadata = {'shape': indata.shape, 'dtype': indata.dtype,
diff --git a/setup.py b/setup.py
index dd55ffb..1d9d020 100644
--- a/setup.py
+++ b/setup.py
@@ -36,7 +36,7 @@ with open("README.md", "r") as fh:
     long_description = fh.read()

 s_required = ["cython>=0.17", "versioneer"]
-i_required = ["contexttimer"]
+i_required = []

 configuration = {
     'name': 'pyrevolve',
-- 
2.17.0