Hi everyone, I am working on the <bug> of ambiguou...
# contribute
n
Hi everyone, I am working on the bug of ambiguous dataclass for Union type (Here is the draft PR). Some questions to discuss: 1. I’m using two Go packages, one licensed under LGPL-2.1 and the other under Apache-2.0. Does anyone know if these licenses permit commercial use? 2. We are planning to support superset dataclasses in Union type, meaning that the expected type of the workflow’s input could be a superset of the user’s input. I am wondering if there are any detailed examples or expected behaviors for nested cases. Please feel free to comment on the PR as well. cc @damp-lion-88352 @cool-lifeguard-49380 @thankful-minister-83577 @damp-rain-31363 Thanks!
d
Hi can you explain question 2 more?
More specific
Nested case? Flyte types? Or something like that?
@nutritious-telephone-58961
n
This is the example I’ve come up with so far. For nested cases, will both of them be considered a superset?
Copy code
from dataclasses import dataclass
from typing import Optional, Union
from flytekit import task, workflow

@dataclass
class A:
    i: int

@dataclass
class B:
    nested_class: A

@dataclass
class C:
    i: int
    j: Optional[int]
    k: int = 5

@task 
def my_task() -> A:
    return A(i=1)

@task 
def foo(input: Union[B, C]):
    print(input)

@workflow
def my_wf():
    a = my_task()
    foo(input=a)
c
No, this should not work, right? You pass an A where you expect a B or C and the only commonality would be that B has an attr of type A. The question is whether inheritance should be supported, meaning B is
class B(A)
.
@thankful-minister-83577 stated this as goal.
I think the union transformer shouldn’t support more or less than when you have a task
@task(b: B)
and the question is whether an
a
is a match.
Regardless of how exactly the the behaviour looks like, I think here in the trivial type checker we need to check “compatability” of the type structure which we currently disregard completely.
f
LGPL might be a problem
h
Good call, @freezing-airport-6809. Let's not use any copyleft dependency, please. That includes LGPL.
d
key question: is LGPL compatible with Apache License?
t
the specific case you’re referring to should not work right? B is not a subclass of A, it just contains an A. i think just a schema check is the most appropriate and is completely sufficient. what are the two libraries you’re looking at?
i think it’s okay to use lgpl but i’m very much not a lawyer. definitely prefer the apache one if the functionality is the same. The Apache website calls out gpl explicitly
We avoid GPLv3 software because merely linking to it is considered by the GPLv3 authors to create a derivative work.
But the L in GPL supposedly allows it
The main difference between the GPL and the LGPL is that the latter allows the work to be linked with (in the case of a library, “used by”) a non-(L)GPLed program.
is the lgpl one much better?
d
cc @nutritious-telephone-58961
n
the specific case you’re referring to should not work right? B is not a subclass of A, it just contains an A. i think just a schema check is the most appropriate and is completely sufficient. what are the two libraries you’re looking at?
So will class C match with an input of class A? Something like the example below:
Copy code
@dataclass
class C(A):
    j: Optional[int]
    k: int = 5
The main problem is that if we plan to support comparing jsonschemas generated from
marshmallow
and
mashumaro
, they have huge differences in their structure. To compare them, we need additional processes. The two libraries I originally used are json_schema_compare and jsonschema, but actually they can not handle all the differences, which means we still need to do some processing before or after by ourselves. We are still finding other useful packages as well. Btw thanks for the clarification of LGPL license!