Skip to content

Commit

Permalink
Allow disabling legacy sublattice path
Browse files Browse the repository at this point in the history
  • Loading branch information
cjao committed May 27, 2024
1 parent 5a69869 commit 58d3cf6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions covalent/_workflow/electron.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import inspect
import json
import operator
import os
import tempfile
from builtins import list
from copy import deepcopy
Expand Down Expand Up @@ -67,6 +68,9 @@
log_stack_info = logger.log_stack_info


DISABLE_LEGACY_SUBLATTICES = os.environ.get("COVALENT_DISABLE_LEGACY_SUBLATTICES") == "1"


class Electron:
"""
An electron (or task) object that is a modular component of a
Expand Down Expand Up @@ -863,8 +867,6 @@ def to_decoded_electron_collection(**x):

# Copied from runner.py
def _build_sublattice_graph(sub: Lattice, json_parent_metadata: str, *args, **kwargs):
import os

parent_metadata = json.loads(json_parent_metadata)
for k in sub.metadata.keys():
if not sub.metadata[k] and k != "triggers":
Expand Down Expand Up @@ -899,5 +901,7 @@ def _build_sublattice_graph(sub: Lattice, json_parent_metadata: str, *args, **kw

except Exception as ex:
# Fall back to legacy sublattice handling
if DISABLE_LEGACY_SUBLATTICES:
raise
print("Falling back to legacy sublattice handling")
return sub.serialize_to_json()

0 comments on commit 58d3cf6

Please sign in to comment.