Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Inline SyntheticFields #49

@cvauclair

Description

@cvauclair

Is your feature request related to a problem? Please describe.
Yes. Currently, SyntheticFields must be explicitly added to a subgraph object. This works when synthetic fields do not need to change after they are defined. However, to have a SyntheticField that changes over the lifetime of a Subgrounds program, one would have to constantly rebind it. Example:

def query_with_n(n: int):
    subgraph.MyEntity.field_plus_n = subgraph.Entity.field + n

    return sg.query([
        subgraph.Query.myEntities.field_plus_n
    ])

Describe the solution you'd like
Add support for inline SyntheticFields:

def query_with_n_inline(n: int):
    sg.query([
        subgraph.Query.myEntities.field + n
    ])

This will require figuring out a naming scheme for the inline SyntheticFields since, due to the fact that they are not explicitly added to an object, they do not have a user defined name. Using our example, something like field_N could work, where N is the number of inline SyntheticField using field as dependency (would have to figure out how to extend this to inline SyntheticFields that have multiple field dependencies).

Describe alternatives you've considered
None.

Additional context
None.

Implementation checklist

  • Add a new function to Subgrounds object to be applied to the fpaths argument of toplevel functions (e.g.: query_df) which will generate temporary transformation layers on the fly for the inline SyntheticFields
  • Tests!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions