From aa348c331295a586ce46b135d516f1ca8cf130f4 Mon Sep 17 00:00:00 2001 From: Jim Kitchen Date: Wed, 13 Nov 2019 11:20:58 -0600 Subject: [PATCH 1/7] Update sha256 --- recipe/meta.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 56b9021dc..2142a9156 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -7,7 +7,7 @@ package: source: url: https://github.com/jim22k/{{ name }}/archive/v{{ version }}.tar.gz - sha256: --- FILL THIS IN --- + sha256: 02659f8fd5239bd4558d15d189227b1e1388c4659f104c876304f37c8de0be9a build: number: 0 @@ -17,11 +17,13 @@ requirements: - python >=3.5 - cffi - ss_graphblas ==3.1.1 + - pytest-runner host: - python >=3.5 - cffi - ss_graphblas ==3.1.1 + - pytest-runner run: - python >=3.5 From f0851507c7b833ed2d29540c71bd6f52fffb2833 Mon Sep 17 00:00:00 2001 From: Jim Kitchen Date: Tue, 19 Nov 2019 11:09:44 -0600 Subject: [PATCH 2/7] Build v1.2.1 --- recipe/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index b6aec2844..799ff5d78 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,5 +1,5 @@ {% set name = "grblas" %} -{% set version = "1.2.0" %} +{% set version = "1.2.1" %} package: name: "{{ name|lower }}" @@ -7,7 +7,7 @@ package: source: url: https://github.com/jim22k/{{ name }}/archive/v{{ version }}.tar.gz - sha256: 02659f8fd5239bd4558d15d189227b1e1388c4659f104c876304f37c8de0be9a + sha256: c7fdcc3cfc5f887de851774e107f86b228a6993e77f81f782f0bcb0dcf30c30a build: number: 0 From acc0eeaa99598b4349afc2e950bb8c831e4d1fe6 Mon Sep 17 00:00:00 2001 From: Jim Kitchen Date: Thu, 23 Jan 2020 16:15:16 -0600 Subject: [PATCH 3/7] Update sha256 --- recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 8b8eeb4d9..a469373d3 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -7,7 +7,7 @@ package: source: url: https://github.com/jim22k/{{ name }}/archive/v{{ version }}.tar.gz - sha256: c7fdcc3cfc5f887de851774e107f86b228a6993e77f81f782f0bcb0dcf30c30a + sha256: 218c948550f34124f9564b6d6c784af13fe32b50c8b6ea80efeec07deebf1bca build: number: 0 From 096d26f49c44fb71f2aa2e93659706a61f39efca Mon Sep 17 00:00:00 2001 From: Jim Kitchen Date: Thu, 23 Jan 2020 18:01:11 -0600 Subject: [PATCH 4/7] Update SHA --- recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index a469373d3..afd006460 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -7,7 +7,7 @@ package: source: url: https://github.com/jim22k/{{ name }}/archive/v{{ version }}.tar.gz - sha256: 218c948550f34124f9564b6d6c784af13fe32b50c8b6ea80efeec07deebf1bca + sha256: e915a0435b9f784e11f46512030e29915d8182a81b620411a156d5819618c3f6 build: number: 0 From 77449f1a25148f29d60d87ad74ad7e9c79eb18a1 Mon Sep 17 00:00:00 2001 From: Jim Kitchen Date: Tue, 10 Mar 2020 10:41:22 -0500 Subject: [PATCH 5/7] Auto-init No longer require users to explicitly call `grblas.init()`. First usage of items within grblas will trigger the auto-init. Attempting to call init() after the auto-init will raise an error. Remove dependency on ss_graphblas; switch to conda-forge's graphblas --- grblas/__init__.py | 66 +++++++++++++++++++++++++++++++++++++--------- recipe/meta.yaml | 14 +++++----- 2 files changed, 60 insertions(+), 20 deletions(-) diff --git a/grblas/__init__.py b/grblas/__init__.py index 6ccaada85..26654da5f 100644 --- a/grblas/__init__.py +++ b/grblas/__init__.py @@ -1,27 +1,58 @@ import importlib from . import backends -lib = None -ffi = None -REPLACE = None -Matrix = None -Vector = None -Scalar = None -UnaryOp, BinaryOp, Monoid, Semiring = None, None, None, None +_init_params = None +_SPECIAL_ATTRS = ["lib", "ffi", "Matrix", "Vector", "Scalar", "UnaryOp", "BinaryOp", "Monoid", "Semiring"] -def init(backend='suitesparse', blocking=True): - global lib, ffi, REPLACE, Matrix, Vector, Scalar, UnaryOp, BinaryOp, Monoid, Semiring + +def __getattr__(name): + """Auto-initialize if special attrs used without explicit init call by user""" + if name in _SPECIAL_ATTRS: + _init("suitesparse", True, automatic=True) + + return globals()[name] + else: + raise AttributeError(f"module {__name__!r} has not attribute {name!r}") + + +def __dir__(): + attrs = list(globals()) + if "lib" not in attrs: + attrs += _SPECIAL_ATTRS + return attrs + + +def init(backend="suitesparse", blocking=True): + _init(backend, blocking) + + +def _init(backend, blocking, automatic=False): + global lib, ffi, REPLACE, Matrix, Vector, Scalar, UnaryOp, BinaryOp, Monoid, Semiring, _init_params + + passed_params = dict(backend=backend, blocking=blocking, automatic=automatic) + if _init_params is None: + _init_params = passed_params + else: + if _init_params != passed_params: + from .exceptions import GrblasException + if _init_params.get("automatic"): + raise GrblasException("grblas objects accessed prior to manual initialization") + else: + raise GrblasException("grblas initialized multiple times with different init parameters") + + # Already initialized with these parameters; nothing more to do + return ffi_backend = importlib.import_module(f'.backends.{backend}', __name__) - lib = ffi_backend.lib - ffi = ffi_backend.ffi + globals()["lib"] = ffi_backend.lib + globals()["ffi"] = ffi_backend.ffi # This must be called before anything else happens if blocking: - lib.GrB_init(lib.GrB_BLOCKING) + ffi_backend.lib.GrB_init(ffi_backend.lib.GrB_BLOCKING) else: - lib.GrB_init(lib.GrB_NONBLOCKING) + ffi_backend.lib.GrB_init(ffi_backend.lib.GrB_NONBLOCKING) from .base import REPLACE from .matrix import Matrix @@ -33,3 +64,12 @@ def init(backend='suitesparse', blocking=True): BinaryOp._initialize() Monoid._initialize() Semiring._initialize() + + globals()["Matrix"] = Matrix + globals()["Vector"] = Vector + globals()["Scalar"] = Scalar + globals()["UnaryOp"] = UnaryOp + globals()["BinaryOp"] = BinaryOp + globals()["Monoid"] = Monoid + globals()["Semiring"] = Semiring + globals()["REPLACE"] = REPLACE diff --git a/recipe/meta.yaml b/recipe/meta.yaml index afd006460..b2e803fb8 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,5 +1,5 @@ {% set name = "grblas" %} -{% set version = "1.2.3" %} +{% set version = "1.2.4" %} package: name: "{{ name|lower }}" @@ -14,21 +14,21 @@ build: requirements: build: - - python >=3.5,<3.8 + - python >=3.6 - cffi - - ss_graphblas ==3.1.1 + - graphblas ==3.1.1 - pytest-runner host: - - python >=3.5,<3.8 + - python >=3.6 - cffi - - ss_graphblas ==3.1.1 + - graphblas ==3.1.1 - pytest-runner run: - - python >=3.5,<3.8 + - python >=3.6 - cffi - - ss_graphblas ==3.1.1 + - graphblas ==3.1.1 - numba about: From ede010d587745bc3462edd04603d19037982c72a Mon Sep 17 00:00:00 2001 From: Jim Kitchen Date: Tue, 17 Mar 2020 10:26:34 -0500 Subject: [PATCH 6/7] Update sha for v1.2.4 --- recipe/meta.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index b2e803fb8..a9058238c 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -7,26 +7,26 @@ package: source: url: https://github.com/jim22k/{{ name }}/archive/v{{ version }}.tar.gz - sha256: e915a0435b9f784e11f46512030e29915d8182a81b620411a156d5819618c3f6 + sha256: 6ef5747a473d600a9daa60db9ef3e3226cc37b52c98afd364364b0c630ddfe6f build: number: 0 requirements: build: - - python >=3.6 + - python - cffi - graphblas ==3.1.1 - pytest-runner host: - - python >=3.6 + - python - cffi - graphblas ==3.1.1 - pytest-runner run: - - python >=3.6 + - python - cffi - graphblas ==3.1.1 - numba From e169f7029bd0342a4b274959a38652c7f9d11d46 Mon Sep 17 00:00:00 2001 From: Jim Kitchen Date: Thu, 9 Apr 2020 12:22:04 -0500 Subject: [PATCH 7/7] Update sha256 --- recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 3bacead29..97751a20b 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -7,7 +7,7 @@ package: source: url: https://github.com/jim22k/{{ name }}/archive/v{{ version }}.tar.gz - sha256: 6ef5747a473d600a9daa60db9ef3e3226cc37b52c98afd364364b0c630ddfe6f + sha256: 91b05d38d8b245359ab2d8b89c066f40600ce82b5d7d2c680bf52e24e45d07d0 build: number: 0