def test_resources():

    @task(requests=Resources(cpu='1'), limits=Resources(cpu='2', mem='400M'))
    def t1(a: int) -> str:
        a = (a + 2)
        return ("now it's " + str(a))

    @task(requests=Resources(cpu='3'))
    def t2(a: int) -> str:
        a = (a + 200)
        return ("now it's " + str(a))

    @workflow
    def my_wf(a: int) -> str:
        x = t1(a=a)
        return x
    serialization_settings = context_manager.SerializationSettings(project='test_proj', domain='test_domain', version='abc', image_config=ImageConfig(Image(name='name', fqn='image', tag='name')), env={})
    with context_manager.FlyteContext.current_context().new_compilation_context():
        sdk_task = get_serializable(serialization_settings, t1)
        assert (sdk_task.container.resources.requests == [_resource_models.ResourceEntry(_resource_models.ResourceName.CPU, '1')])
        assert (sdk_task.container.resources.limits == [_resource_models.ResourceEntry(_resource_models.ResourceName.CPU, '2'), _resource_models.ResourceEntry(_resource_models.ResourceName.MEMORY, '400M')])
        sdk_task2 = get_serializable(serialization_settings, t2)
        assert (sdk_task2.container.resources.requests == [_resource_models.ResourceEntry(_resource_models.ResourceName.CPU, '3')])
        assert (sdk_task2.container.resources.limits == [])
def test_resources():

    @task(requests=Resources(cpu='1'), limits=Resources(cpu='2', mem='400M'))
    def t1(a: int) -> str:
        a = (a + 2)
        return ("now it's " + str(a))

    @task(requests=Resources(cpu='3'))
    def t2(a: int) -> str:
        a = (a + 200)
        return ("now it's " + str(a))

    @workflow
    def my_wf(a: int) -> str:
        x = t1(a=a)
        return x
    serialization_settings = context_manager.SerializationSettings(project='test_proj', domain='test_domain', version='abc', image_config=ImageConfig(Image(name='name', fqn='image', tag='name')), env={})
    with context_manager.FlyteContext.current_context().new_compilation_context():
        sdk_task = get_serializable(serialization_settings, t1)
        assert (sdk_task.container.resources.requests == [_resource_models.ResourceEntry(_resource_models.ResourceName.CPU, '1')])
        assert (sdk_task.container.resources.limits == [_resource_models.ResourceEntry(_resource_models.ResourceName.CPU, '2'), _resource_models.ResourceEntry(_resource_models.ResourceName.MEMORY, '400M')])
        sdk_task2 = get_serializable(serialization_settings, t2)
        assert (sdk_task2.container.resources.requests == [_resource_models.ResourceEntry(_resource_models.ResourceName.CPU, '3')])
        assert (sdk_task2.container.resources.limits == [])