Skip to content

Commit

Permalink
experiment #2
Browse files Browse the repository at this point in the history
  • Loading branch information
aszs committed Nov 13, 2024
1 parent 1c798bb commit a38ad87
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion tests/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ def test_computed_properties():
}
# XXX we need to delete this module because mytypes gets re-evaluated, breaking class identity
# is this a scenario we need to worry about outside unit tests?
del sys.modules['service_template.mytypes']
result, job, summary = run_job_cmd(
cli_runner, ["-vvv", "undeploy"], print_result=True
)
Expand Down
7 changes: 6 additions & 1 deletion tosca-package/tosca/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ def restricted_exec(
)
package, sep, module_name = full_name.rpartition(".")
if modules is None:
logger.warning(f"!!!! {full_name} {safe_mode}, {global_state.modules is sys.modules}")
modules = global_state.modules if safe_mode else sys.modules

if namespace is None:
Expand Down Expand Up @@ -748,6 +749,7 @@ def restricted_exec(
sys.modules[full_name] = temp_module
previous_safe_mode = global_state.safe_mode
previous_mode = global_state.mode
logger.warning("00000000000 %s %s", full_name, temp_module)
try:
global_state.safe_mode = safe_mode
global_state.mode = "spec"
Expand All @@ -757,9 +759,12 @@ def restricted_exec(
namespace.update(temp_module.__dict__)
else:
exec(result.code, namespace)
except:
logger.warning("ASDFASDFASDFASDF %s %s", full_name, temp_module)
raise
finally:
global_state.safe_mode = previous_safe_mode
global_state.mode = previous_mode
if safe_mode and temp_module:
if temp_module:
del sys.modules[full_name]
return result
3 changes: 3 additions & 0 deletions unfurl/planrequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from toscaparser.elements.interfaces import OperationDef
from toscaparser.nodetemplate import NodeTemplate
from .spec import ArtifactSpec, EntitySpec
import tosca

if TYPE_CHECKING:
from .job import Job, ConfigTask, JobOptions
Expand Down Expand Up @@ -130,6 +131,8 @@ def create(self) -> "Configurator":
from .dsl import DslMethodConfigurator

module_name, qualname, action = className.split(":")
logger.warning("loading dsl configurator", module_name, tosca.safe_mode())
assert not tosca.safe_mode(), module_name
module = importlib.import_module(module_name)
cls_name, sep, func_name = qualname.rpartition(".")
cls = getattr(module, cls_name)
Expand Down

0 comments on commit a38ad87

Please sign in to comment.