@@ -66,79 +66,45 @@ jobs:
6666 name : benchmark_gpu_common/prepare-matrix
6767 runs-on : ubuntu-latest
6868 outputs :
69- command : ${{ steps.set_command.outputs.command }}
70- op_flavor : ${{ steps.set_op_flavor.outputs.op_flavor }}
71- bench_type : ${{ steps.set_bench_type.outputs.bench_type }}
72- params_type : ${{ steps.set_params_type.outputs.params_type }}
73- env :
74- INPUTS_COMMAND : ${{ inputs.command }}
75- INPUTS_OP_FLAVOR : ${{ inputs.op_flavor }}
69+ command : ${{ steps.set_matrix_args.outputs.command }}
70+ op_flavor : ${{ steps.set_matrix_args.outputs.op_flavor }}
71+ bench_type : ${{ steps.set_matrix_args.outputs.bench_type }}
72+ params_type : ${{ steps.set_matrix_args.outputs.params_type }}
7673 steps :
77- - name : Set single command
78- if : ${{ !contains(inputs.command, ',')}}
79- run : |
80- echo "COMMAND=[\"${INPUTS_COMMAND}\"]" >> "${GITHUB_ENV}"
81-
82- - name : Set multiple commands
83- if : ${{ contains(inputs.command, ',')}}
84- run : |
85- # Use Sed to extract a value from a string, this cannot be done with the ${variable//search/replace} pattern.
86- # shellcheck disable=SC2001
87- PARSED_COMMAND=$(echo "${INPUTS_COMMAND}" | sed 's/[[:space:]]*,[[:space:]]*/\", \"/g')
88- echo "COMMAND=[\"${PARSED_COMMAND}\"]" >> "${GITHUB_ENV}"
89-
90- - name : Set single operations flavor
91- if : ${{ !contains(inputs.op_flavor, ',')}}
92- run : |
93- echo "OP_FLAVOR=[\"${INPUTS_OP_FLAVOR}\"]" >> "${GITHUB_ENV}"
94-
95- - name : Set multiple operations flavors
96- if : ${{ contains(inputs.op_flavor, ',')}}
97- run : |
98- # Use Sed to extract a value from a string, this cannot be done with the ${variable//search/replace} pattern.
99- # shellcheck disable=SC2001
100- PARSED_OP_FLAVOR=$(echo "${INPUTS_OP_FLAVOR}" | sed 's/[[:space:]]*,[[:space:]]*/", "/g')
101- echo "OP_FLAVOR=[\"${PARSED_OP_FLAVOR}\"]" >> "${GITHUB_ENV}"
102-
103- - name : Set benchmark types
104- run : |
105- if [[ "${INPUTS_BENCH_TYPE}" == "both" ]]; then
106- echo "BENCH_TYPE=[\"latency\", \"throughput\"]" >> "${GITHUB_ENV}"
107- else
108- echo "BENCH_TYPE=[\"${INPUTS_BENCH_TYPE}\"]" >> "${GITHUB_ENV}"
109- fi
110- env :
111- INPUTS_BENCH_TYPE : ${{ inputs.bench_type }}
112-
113- - name : Set parameters types
114- run : |
115- if [[ "${INPUTS_PARAMS_TYPE}" == "both" ]]; then
116- echo "PARAMS_TYPE=[\"classical\", \"multi_bit\"]" >> "${GITHUB_ENV}"
117- else
118- echo "PARAMS_TYPE=[\"${INPUTS_PARAMS_TYPE}\"]" >> "${GITHUB_ENV}"
119- fi
120- env :
121- INPUTS_PARAMS_TYPE : ${{ inputs.params_type }}
122-
123- - name : Set command output
124- id : set_command
125- run : | # zizmor: ignore[template-injection] this env variable is safe
126- echo "command=${{ toJSON(env.COMMAND) }}" >> "${GITHUB_OUTPUT}"
127-
128- - name : Set operation flavor output
129- id : set_op_flavor
130- run : | # zizmor: ignore[template-injection] this env variable is safe
131- echo "op_flavor=${{ toJSON(env.OP_FLAVOR) }}" >> "${GITHUB_OUTPUT}"
132-
133- - name : Set benchmark types output
134- id : set_bench_type
135- run : | # zizmor: ignore[template-injection] this env variable is safe
136- echo "bench_type=${{ toJSON(env.BENCH_TYPE) }}" >> "${GITHUB_OUTPUT}"
137-
138- - name : Set parameters types output
139- id : set_params_type
140- run : | # zizmor: ignore[template-injection] this env variable is safe
141- echo "params_type=${{ toJSON(env.PARAMS_TYPE) }}" >> "${GITHUB_OUTPUT}"
74+ - name : Parse user inputs
75+ shell : python
76+ run : | # zizmor: ignore[template-injection] these env variables are safe
77+ split_command = "${{ inputs.command }}".replace(" ", "").split(",")
78+ split_op_flavor = "${{ inputs.op_flavor }}".replace(" ", "").split(",")
79+
80+ if "${{ inputs.bench_type }}" == "both":
81+ bench_type = ["latency", "throughput"]
82+ else:
83+ bench_type = ["${{ inputs.bench_type }}", ]
84+
85+ if "+" in "${{ inputs.params_type }}":
86+ split_params_type= "${{ inputs.params_type }}".replace(" ", "").split("+")
87+ else:
88+ split_params_type = ["${{ inputs.params_type }}", ]
89+
90+ with open("${{ github.env }}", "a") as f:
91+ for env_name, values_to_join in [
92+ ("COMMAND", split_command),
93+ ("OP_FLAVOR", split_op_flavor),
94+ ("BENCH_TYPE", bench_type),
95+ ("PARAMS_TYPE", split_params_type),
96+ ]:
97+ f.write(f"""{env_name}=["{'", "'.join(values_to_join)}"]\n""")
98+
99+ - name : Set martix arguments outputs
100+ id : set_matrix_args
101+ run : | # zizmor: ignore[template-injection] these env variable are safe
102+ {
103+ echo "command=${{ toJSON(env.COMMAND) }}";
104+ echo "op_flavor=${{ toJSON(env.OP_FLAVOR) }}";
105+ echo "bench_type=${{ toJSON(env.BENCH_TYPE) }}";
106+ echo "params_type=${{ toJSON(env.PARAMS_TYPE) }}";
107+ } >> "${GITHUB_OUTPUT}"
142108
143109 setup-instance :
144110 name : benchmark_gpu_common/setup-instance
0 commit comments