Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TRIS-722] Custom Tagging #2144

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

RikishK
Copy link

@RikishK RikishK commented Nov 13, 2024

Options to add custom tags are in the order:

environment variable dictionary,
step functions cli create flag,
batch decorator variable dictionary

This PR builds ontop of this PR: #1628 - this original PR did not work when testing but I would like to credit it here as some of the changes are still used.

@RikishK RikishK force-pushed the fsat/pr-1627--rebased--2.12.28 branch from 7a3be98 to 66e562e Compare November 14, 2024 05:36
@RikishK RikishK force-pushed the fsat/pr-1627--rebased--2.12.28 branch from edd8055 to e178c81 Compare November 18, 2024 04:28
@RikishK RikishK force-pushed the fsat/pr-1627--rebased--2.12.28 branch from dd7073a to 00be0f0 Compare November 19, 2024 01:52
@RikishK RikishK force-pushed the fsat/pr-1627--rebased--2.12.28 branch 3 times, most recently from 2810093 to 0d45ad5 Compare November 21, 2024 05:13
@RikishK RikishK force-pushed the fsat/pr-1627--rebased--2.12.28 branch from 0d45ad5 to 4c5cebf Compare November 22, 2024 02:38
@RikishK
Copy link
Author

RikishK commented Nov 25, 2024

Testing

Setup:

Environment variable:

{ name: 'METAFLOW_BATCH_EMIT_TAGS', value: 'True' },
{ name: 'METAFLOW_BATCH_DEFAULT_TAGS', value: '{"default_greeting": "default_world"}' }

Step functions create command:

step-functions create --aws-tags "hello=world"

Flow:

from metaflow import (
    FlowSpec,
    step,
    batch,
    retry,
    schedule,
    project,
    conda,
    current
)
import logging
import logging_setup

logging_setup.configure()


custom_step_tags = {
    "goodbye": "world",
    "hello": "universe",
   #"inv@lid": "t@g"
    }

@project(name="ml_apac_trisolaris")
@schedule(hourly=True)
class CanarySimpleAdhoc(FlowSpec):
    @step
    def start(self):
        self.logger = logging.getLogger(self.__class__.__name__)
        self.logger.info(f"Canary Hello")
        self.next(self.hello)

    @batch(cpu=1, memory=500, tags=custom_step_tags)
    @retry
    @step
    def hello(self):
        self.logger.info("Canary Hello World in Batch!")
        self.next(self.end)

    @step
    def end(self):
        self.logger.info("HelloAWS is finished.")


if __name__ == "__main__":
    CanarySimpleAdhoc()

Output/Result:

Start step batch tags:
image

Hello step batch tags:
image

Additional notes:
Tag validation was tested with "inv@lid": "t@g" which caused an error as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants