Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

df: base: op should extrapolate inputs based off typing information #189

@johnandersen777

Description

@johnandersen777

Related: #188

    >>> @op(inputs={"host": HOST, "port": PORT, "message": MESSAGE})
    ... async def send_to_server(host: str, port: int, message: str):
    ...     reader, writer = await asyncio.open_connection(host, port)
    ...
    ...     writer.write(message.encode())
    ...     await writer.drain()
    ...
    ...     data = await reader.read(100)
    ...     print(f"Client sent {message!r}, got: {data.decode()!r}")
    ...
    ...     writer.close()
    ...     await writer.wait_closed()

We had to pass inputs to op and create all the Defintion instances.

What would be good is to modify dffml/df/base.py so that if op is not provided with inputs it uses inspect.signature to look at the functions arguments. It should create Defintions for each argument using the str(of the data type) as the primitive and the name as the name.

Also add some validation to make sure that we can only do this for data types which are already primitives, aka, int, float, str, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestp2Medium PrioritytSEsitmated Time To Complete: Short

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions