How to use the dffml.df.types.DataFlow function in dffml

To help you get started, we’ve selected a few dffml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intel / dffml / tests / integration / test_service_dev.py View on Github external
async def test_export(self):
        self.required_plugins("shouldi")
        stdout = io.StringIO()
        # Use shouldi's dataflow for tests
        with relative_chdir("..", "..", "examples", "shouldi"):
            with unittest.mock.patch("sys.stdout.buffer.write") as write:
                await Develop.cli("export", "shouldi.cli:DATAFLOW")
            DataFlow._fromdict(**json.loads(write.call_args[0][0]))
github intel / dffml / dffml / operation / output.py View on Github external
def _fromdict(cls, **kwargs):
        kwargs["dataflow"] = DataFlow._fromdict(**kwargs["dataflow"])
        return cls(**kwargs)
github intel / dffml / service / http / dffml_service_http / routes.py View on Github external
def _fromdict(cls, **kwargs):
        kwargs["dataflow"] = DataFlow._fromdict(**kwargs["dataflow"])
        return cls(**kwargs)
github intel / dffml / dffml / cli / dataflow.py View on Github external
async def run(self):
        dataflow_path = pathlib.Path(self.dataflow)
        config_cls = self.config
        if config_cls is None:
            config_type = dataflow_path.suffix.replace(".", "")
            config_cls = BaseConfigLoader.load(config_type)
        async with config_cls.withconfig(self.extra_config) as configloader:
            async with configloader() as loader:
                exported = await loader.loadb(dataflow_path.read_bytes())
                dataflow = DataFlow._fromdict(**exported)
        async with self.orchestrator as orchestrator, self.sources as sources:
            async for repo in self.run_dataflow(
                orchestrator, sources, dataflow
            ):
                yield repo
github intel / dffml / dffml / service / dev.py View on Github external
async def run(self):
        async with self.config(BaseConfig()) as configloader:
            async with configloader() as loader:
                for obj in load(self.export, relative=os.getcwd()):
                    self.logger.debug("Loaded %s: %s", self.export, obj)
                    if isinstance(obj, DataFlow):
                        sys.stdout.buffer.write(
                            await loader.dumpb(
                                obj.export(linked=not self.not_linked)
                            )
                        )
                    elif hasattr(obj, "export"):
                        sys.stdout.buffer.write(
                            await loader.dumpb(obj.export())
                        )
                    elif hasattr(obj, "_asdict"):
                        sys.stdout.buffer.write(
                            await loader.dumpb(obj._asdict())
                        )
github intel / dffml / dffml / operation / output.py View on Github external
key, value = exported
        # Acquire all definitions within the context
        async with self.octx.ictx.definitions(self.ctx) as od:
            # Output dict
            want = {}
            async for item in od.inputs(value):
                parents = item.get_parents()
                for parent in parents:
                    if key == parent.definition:
                        want[parent.value] = item.value
                        break
            return {value.name: want}


class RemapConfig(NamedTuple):
    dataflow: DataFlow

    @classmethod
    def _fromdict(cls, **kwargs):
        kwargs["dataflow"] = DataFlow._fromdict(**kwargs["dataflow"])
        return cls(**kwargs)


class RemapFailure(Exception):
    """
    Raised whem results of a dataflow could not be remapped.
    """


# TODO Make it so that only one output operation gets run, the result of that
# operation is the result of the dataflow
@op(
github intel / dffml / service / http / dffml_service_http / routes.py View on Github external
request.match_info["label"], None
        )
        if mctx is None:
            return web.json_response(
                MODEL_NOT_LOADED, status=HTTPStatus.NOT_FOUND
            )
        return await handler(self, request, mctx)

    return get_mctx


class HTTPChannelConfig(NamedTuple):
    path: str
    presentation: str
    asynchronous: bool
    dataflow: DataFlow

    @classmethod
    def _fromdict(cls, **kwargs):
        kwargs["dataflow"] = DataFlow._fromdict(**kwargs["dataflow"])
        return cls(**kwargs)


@entry_point("http")
class Routes(BaseMultiCommContext):
    PRESENTATION_OPTIONS = ["json", "blob", "text"]

    async def get_registered_handler(self, request):
        return self.app["multicomm_routes"].get(request.path, None)

    async def multicomm_dataflow(self, config, request):
        # Seed the network with inputs given by caller