Created
August 30, 2023 03:27
-
-
Save pdxjohnny/c506144965ef625c7e0e6a5169eb13cb to your computer and use it in GitHub Desktop.
dffml: auto gen static code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/dffml/df/base.py b/dffml/df/base.py | |
index 0819cb7e3..9cc7d6aea 100644 | |
--- a/dffml/df/base.py | |
+++ b/dffml/df/base.py | |
@@ -601,6 +601,7 @@ def op( | |
), | |
}, | |
) | |
+ func.imp.func = func | |
return func | |
# This case handles if op was called with no arguments, args will be a tuple | |
diff --git a/dffml/df/memory.py b/dffml/df/memory.py | |
index 67342c0fc..216671237 100644 | |
--- a/dffml/df/memory.py | |
+++ b/dffml/df/memory.py | |
@@ -1257,6 +1257,15 @@ class MemoryOperationImplementationNetworkContext( | |
await self.completed_event.wait() | |
self.completed_event.clear() | |
+ @staticmethod | |
+ def camel_to_underscore(camel_str): | |
+ underscore_str = "" | |
+ for i, char in enumerate(camel_str): | |
+ if char.isupper() and (i + 1 < len(camel_str) and not camel_str[i + 1].isupper()) and i != 0 : | |
+ underscore_str += "_" | |
+ underscore_str += char.lower() | |
+ return underscore_str | |
+ | |
async def run_dispatch( | |
self, | |
octx: BaseOrchestratorContext, | |
@@ -1271,6 +1280,16 @@ class MemoryOperationImplementationNetworkContext( | |
# Ensure that we can run the operation | |
# Lock all inputs which cannot be used simultaneously | |
async with octx.lctx.acquire(parameter_set, operation=operation): | |
+ print( | |
+ ", ".join([f"{self.camel_to_underscore(p.name)}" for p in operation.outputs.values()]), | |
+ "=", | |
+ "asyncio.run(" if inspect.iscoroutinefunction(self.operations[operation.instance_name].func) else "", | |
+ operation.name.replace(":", "."), | |
+ "(", | |
+ ", ".join([f"{self.camel_to_underscore(p.origin.definition.name)}" for p in parameter_set.config.parameters]), | |
+ ")", | |
+ ")" if inspect.iscoroutinefunction(self.operations[operation.instance_name].func) else "", | |
+ ) | |
# Run the operation | |
outputs = await self.run( | |
parameter_set.ctx, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment