Last active
June 6, 2023 15:16
-
-
Save pdxjohnny/7876a0de6e2b318ffbfa7eabaacf172b to your computer and use it in GitHub Desktop.
$ git diff d1283f6564423ed1a08713deffbd6ab38a4cdcee fb8a7b92c52aaccf3fae2821235472686b3576a9^ '**/*.py' https://github.com/intel/dffml
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/memory.py b/dffml/df/memory.py | |
index aaddea98a..fae38d786 100644 | |
--- a/dffml/df/memory.py | |
+++ b/dffml/df/memory.py | |
@@ -1975,7 +1975,8 @@ class MemoryOrchestratorContext(BaseOrchestratorContext): | |
output = {} | |
async for operation, results in self.run_stage(ctx, Stage.OUTPUT): | |
output.setdefault(operation.instance_name, {}) | |
- output[operation.instance_name].update(results) | |
+ if results is not None: | |
+ output[operation.instance_name].update(results) | |
except: | |
if strict: | |
raise | |
diff --git a/dffml/source/json.py b/dffml/source/json.py | |
index f283e86ea..5cbec1a25 100644 | |
--- a/dffml/source/json.py | |
+++ b/dffml/source/json.py | |
@@ -10,6 +10,7 @@ from ..record import Record | |
from .memory import MemorySource | |
from .file import FileSource, FileSourceConfig | |
from ..util.entrypoint import entrypoint | |
+from ..util.data import export_dict | |
from .log import LOGGER | |
@@ -86,6 +87,6 @@ class JSONSource(FileSource, MemorySource): | |
self.logger.debug(f"{self.config.filename} updated") | |
if await self.OPEN_JSON_FILES[self.config.filename].dec(): | |
del self.OPEN_JSON_FILES[self.config.filename] | |
- json.dump(records, fd) | |
+ json.dump(export_dict(result=records)["result"], fd) | |
self.logger.debug(f"{self.config.filename} written") | |
LOGGER.debug("%r saved %d records", self, len(self.mem)) | |
diff --git a/dffml/util/data.py b/dffml/util/data.py | |
index 6014a2217..73db2d820 100644 | |
--- a/dffml/util/data.py | |
+++ b/dffml/util/data.py | |
@@ -249,6 +249,9 @@ def export_value(obj, key, value): | |
obj[key] = value.export() | |
elif hasattr(value, "_asdict"): | |
obj[key] = value._asdict() | |
+ elif hasattr(value, "dict"): | |
+ # https://docs.pydantic.dev/usage/exporting_models/#model | |
+ obj[key] = value.dict() | |
elif "numpy" in typename_lower: | |
if isinstance(value, collections.abc.Iterable) and isinstance( | |
getattr(value, "tolist", None), collections.abc.Callable | |
diff --git a/operations/innersource/dffml_operations_innersource/actions_validator.py b/operations/innersource/dffml_operations_innersource/actions_validator.py | |
index b0198458c..8cca11790 100644 | |
--- a/operations/innersource/dffml_operations_innersource/actions_validator.py | |
+++ b/operations/innersource/dffml_operations_innersource/actions_validator.py | |
@@ -11,7 +11,7 @@ from dffml_operations_innersource.operations import ( | |
ActionsValidatorBinary = NewType("ActionsValidatorBinary", str) | |
-ActionsValidatorResult = NewType("ActionsValidatorResult", str) | |
+ActionsValidatorResult = NewType("ActionsValidatorResult", dict) | |
@dffml.op | |
@@ -53,6 +53,9 @@ async def actions_validator( | |
>>> print(asyncio.run(main())) | |
True | |
""" | |
+ exit_code = -1 | |
+ stderr = "" | |
+ items = None | |
async for event, result in dffml.run_command_events( | |
[ | |
str(actions_validator_binary), | |
@@ -70,7 +73,14 @@ async def actions_validator( | |
if event is dffml.Subprocess.STDOUT and logger: | |
logger.debug("Passed validation: %s", result.decode()) | |
elif event is dffml.Subprocess.STDERR and logger: | |
- logger.debug("Failed validation: %s", result.decode()) | |
+ stderr = result.decode() | |
+ logger.debug("Failed validation: %s", stderr) | |
+ # TODO Parse output into dict or data model | |
+ items = stderr | |
elif event is dffml.Subprocess.COMPLETED: | |
- # TODO Multi output return of stdout / stderr | |
- return bool(result == 0) | |
+ exit_code = result | |
+ return { | |
+ "pass": bool(exit_code == 0), | |
+ "exit_code": exit_code, | |
+ "items": items, | |
+ } | |
diff --git a/operations/innersource/dffml_operations_innersource/npm_groovy_lint.py b/operations/innersource/dffml_operations_innersource/npm_groovy_lint.py | |
index 1ba9c814f..7a33087ca 100644 | |
--- a/operations/innersource/dffml_operations_innersource/npm_groovy_lint.py | |
+++ b/operations/innersource/dffml_operations_innersource/npm_groovy_lint.py | |
@@ -54,6 +54,7 @@ async def code_narc_server( | |
), | |
"com.nvuillam.CodeNarcServer", | |
"--server", | |
+ r"includes='{}/.groovy'", | |
], | |
env=env, | |
logger=logger, | |
diff --git a/operations/innersource/dffml_operations_innersource/operations.py b/operations/innersource/dffml_operations_innersource/operations.py | |
index 22d49dbb7..c8bcce542 100644 | |
--- a/operations/innersource/dffml_operations_innersource/operations.py | |
+++ b/operations/innersource/dffml_operations_innersource/operations.py | |
@@ -238,6 +238,23 @@ def repo_directory(self, repo: git_repository_checked_out.spec) -> RepoDirectory | |
return {"result": repo.directory} | |
+RepoURL = NewType("RepoURL", str) | |
+ | |
+ | |
+@dffml.op( | |
+ inputs={"repo": git_repository_checked_out,}, | |
+ outputs={"result": RepoURL}, | |
+) | |
+def repo_url(self, repo: git_repository_checked_out.spec) -> RepoURL: | |
+ """ | |
+ Helper opertion to expose repo URL of checked out repo object. | |
+ | |
+ TODO Remove this in favor of some kind of mapping extract style on objects | |
+ ref engineering logs for more notes on @op.mapping.extract style decorator. | |
+ """ | |
+ return {"result": repo.URL} | |
+ | |
+ | |
HasDocs = NewType("HasDocs", dict) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment