Skip to content

Resources on node tags not working #28

Description

Problem :

Hello, I have tried to add a specific resource for my node tagged 'training', but this doesn't work. Here is my sagemaker.yaml :

Image

And here is my data_science pipeline :

Image

Kedro-Sagemaker instead put the default ml.t3.medium for my nodes tagged 'training' instead of ml.g4dn.xlarge

Solution :

This is due to this particular piece of code : KedroSageMakerGenerator._get_resources_for_node, particularly this code :

        node_resources = next(
            (
                self.config.aws.resources.get(n)
                for n in chain([node.name], iter(node.tags))
            ),
            None,
        )

This returns the next resources available which is always going to be the node one, even if it None. The correct logic should be something like :

        node_resources = next(
            (
                self.config.aws.resources.get(n)
                for n in chain([node.name], iter(node.tags)) **if self.config.aws.resources.get(n) is not None**
            ),
            None,
        )

Error :

You can test with this little script :

from itertools import chain

resources = {'__default__': dict(instance_type='ml.t3.medium'), 'training': dict(instance_type='ml.g4dn.xlarge')}

node_resources = next(
    (
        resources.get(n)
        for n in chain(['split_data_node'], iter(['training']))
    ),
    None,
)

print(node_resources)

This will return None but should return dict(instance_type='ml.g4dn.xlarge')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions