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

Add matrix strategy for targets #81

Open
xmnlab opened this issue Jan 11, 2024 · 1 comment
Open

Add matrix strategy for targets #81

xmnlab opened this issue Jan 11, 2024 · 1 comment
Labels
psf-grant-proposal Issues used for a PSF grant proposal size:large >16h

Comments

@xmnlab
Copy link
Member

xmnlab commented Jan 11, 2024

In some cases we would like to run a same command for multiples parameters. Currently it is possible using a "for loop" (in bash, or xonsh, etc) or using jinja2 "for loop".

it would be nice to do that using a matrix strategy, similar to what github actions does (for a entire job).

NOTE: matrix will be implemented just for "task scope".

Example:

version: 1.0.0
groups:
  main:
    env-file: .env
    tasks:
      print:
        help: print the values from a matrix strategy
        matrix:
          mytext: 
            - text1
            - text2
            - text3
        run: echo {{ matrix.mytext }}

when the command makim main.print is executed, it will run "echo" for each value in mytext list.
if more variables is defined in the matrix, it will run the run section for all the combination of variables.
the values for each variable in the matrix, should be a list

@xmnlab xmnlab added psf-grant-proposal Issues used for a PSF grant proposal size:large >16h labels Feb 16, 2024
@xmnlab
Copy link
Member Author

xmnlab commented Oct 7, 2024

so maybe we just need to wrap-up the final section:

    FOR VARS IN MATRIX:   # THIS LINE IS A PSEUDOCODE
        UPDATE_MATRIX_VARS()  # THIS LINE IS A PSEUDOCODE
        if self.verbose:
            MakimLogs.print_info('=' * width)
            MakimLogs.print_info(
                'TARGET: ' + f'{self.group_name}.{self.task_name}'
            )
            MakimLogs.print_info('ARGS:')
            MakimLogs.print_info(pprint.pformat(args_input))
            MakimLogs.print_info('VARS:')
            MakimLogs.print_info(pprint.pformat(variables))
            MakimLogs.print_info('ENV:')
            MakimLogs.print_info(str(env))
 
            IF MATRIX:
                MakimLogs.print_info('MATRIX:')
                MakimLogs.print_info(str(matrix_vars))
            MakimLogs.print_info('-' * width)
            MakimLogs.print_info('>>> ' + cmd.replace('\n', '\n>>> '))
            MakimLogs.print_info('=' * width)

        if not self.dry_run and cmd:
            self._call_shell_app(cmd)

by wrap-up I mean that that section would be executed inside the matrix. Additionally, in that section it should set the variables from the matrix.

we probably don't need to wrap-up the final lines, they should just run once at the end:

        # move back the environment variable to the previous values
        os.environ.clear()
        os.environ.update(self.env_scoped)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
psf-grant-proposal Issues used for a PSF grant proposal size:large >16h
Projects
None yet
Development

No branches or pull requests

1 participant