mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-07 22:04:10 -05:00
chore(ci): handle inputs vars safely in python script
This commit is contained in:
31
.github/workflows/benchmark_cpu_common.yml
vendored
31
.github/workflows/benchmark_cpu_common.yml
vendored
@@ -71,21 +71,34 @@ jobs:
|
||||
steps:
|
||||
- name: Parse user inputs
|
||||
shell: python
|
||||
run: | # zizmor: ignore[template-injection] these env variables are safe
|
||||
split_command = "${{ inputs.command }}".replace(" ", "").split(",")
|
||||
split_op_flavor = "${{ inputs.op_flavor }}".replace(" ", "").split(",")
|
||||
env:
|
||||
INPUTS_COMMAND: ${{ inputs.command }}
|
||||
INPUTS_OP_FLAVOR: ${{ inputs.op_flavor }}
|
||||
INPUTS_BENCH_TYPE: ${{ inputs.bench_type }}
|
||||
INPUTS_PARAMS_TYPE: ${{ inputs.params_type }}
|
||||
run: |
|
||||
import os
|
||||
|
||||
if "${{ inputs.bench_type }}" == "both":
|
||||
inputs_command = os.environ["INPUTS_COMMAND"]
|
||||
inputs_op_flavor = os.environ["INPUTS_OP_FLAVOR"]
|
||||
inputs_bench_type = os.environ["INPUTS_BENCH_TYPE"]
|
||||
inputs_params_type = os.environ["INPUTS_PARAMS_TYPE"]
|
||||
env_file = os.environ["GITHUB_ENV"]
|
||||
|
||||
split_command = inputs_command.replace(" ", "").split(",")
|
||||
split_op_flavor = inputs_op_flavor.replace(" ", "").split(",")
|
||||
|
||||
if inputs_bench_type == "both":
|
||||
bench_type = ["latency", "throughput"]
|
||||
else:
|
||||
bench_type = ["${{ inputs.bench_type }}", ]
|
||||
bench_type = [inputs_bench_type, ]
|
||||
|
||||
if "+" in "${{ inputs.params_type }}":
|
||||
split_params_type= "${{ inputs.params_type }}".replace(" ", "").split("+")
|
||||
if "+" in inputs_params_type:
|
||||
split_params_type= inputs_params_type.replace(" ", "").split("+")
|
||||
else:
|
||||
split_params_type = ["${{ inputs.params_type }}", ]
|
||||
split_params_type = [inputs_params_type, ]
|
||||
|
||||
with open("${{ github.env }}", "a") as f:
|
||||
with open(env_file, "a") as f:
|
||||
for env_name, values_to_join in [
|
||||
("COMMAND", split_command),
|
||||
("OP_FLAVOR", split_op_flavor),
|
||||
|
||||
31
.github/workflows/benchmark_gpu_common.yml
vendored
31
.github/workflows/benchmark_gpu_common.yml
vendored
@@ -73,21 +73,34 @@ jobs:
|
||||
steps:
|
||||
- name: Parse user inputs
|
||||
shell: python
|
||||
run: | # zizmor: ignore[template-injection] these env variables are safe
|
||||
split_command = "${{ inputs.command }}".replace(" ", "").split(",")
|
||||
split_op_flavor = "${{ inputs.op_flavor }}".replace(" ", "").split(",")
|
||||
env:
|
||||
INPUTS_COMMAND: ${{ inputs.command }}
|
||||
INPUTS_OP_FLAVOR: ${{ inputs.op_flavor }}
|
||||
INPUTS_BENCH_TYPE: ${{ inputs.bench_type }}
|
||||
INPUTS_PARAMS_TYPE: ${{ inputs.params_type }}
|
||||
run: |
|
||||
import os
|
||||
|
||||
if "${{ inputs.bench_type }}" == "both":
|
||||
inputs_command = os.environ["INPUTS_COMMAND"]
|
||||
inputs_op_flavor = os.environ["INPUTS_OP_FLAVOR"]
|
||||
inputs_bench_type = os.environ["INPUTS_BENCH_TYPE"]
|
||||
inputs_params_type = os.environ["INPUTS_PARAMS_TYPE"]
|
||||
env_file = os.environ["GITHUB_ENV"]
|
||||
|
||||
split_command = inputs_command.replace(" ", "").split(",")
|
||||
split_op_flavor = inputs_op_flavor.replace(" ", "").split(",")
|
||||
|
||||
if inputs_bench_type == "both":
|
||||
bench_type = ["latency", "throughput"]
|
||||
else:
|
||||
bench_type = ["${{ inputs.bench_type }}", ]
|
||||
bench_type = [inputs_bench_type, ]
|
||||
|
||||
if "+" in "${{ inputs.params_type }}":
|
||||
split_params_type= "${{ inputs.params_type }}".replace(" ", "").split("+")
|
||||
if "+" in inputs_params_type:
|
||||
split_params_type= inputs_params_type.replace(" ", "").split("+")
|
||||
else:
|
||||
split_params_type = ["${{ inputs.params_type }}", ]
|
||||
split_params_type = [inputs_params_type, ]
|
||||
|
||||
with open("${{ github.env }}", "a") as f:
|
||||
with open(env_file, "a") as f:
|
||||
for env_name, values_to_join in [
|
||||
("COMMAND", split_command),
|
||||
("OP_FLAVOR", split_op_flavor),
|
||||
|
||||
23
.github/workflows/benchmark_hpu_common.yml
vendored
23
.github/workflows/benchmark_hpu_common.yml
vendored
@@ -67,16 +67,27 @@ jobs:
|
||||
steps:
|
||||
- name: Parse user inputs
|
||||
shell: python
|
||||
run: | # zizmor: ignore[template-injection] these env variables are safe
|
||||
split_command = "${{ inputs.command }}".replace(" ", "").split(",")
|
||||
split_op_flavor = "${{ inputs.op_flavor }}".replace(" ", "").split(",")
|
||||
env:
|
||||
INPUTS_COMMAND: ${{ inputs.command }}
|
||||
INPUTS_OP_FLAVOR: ${{ inputs.op_flavor }}
|
||||
INPUTS_BENCH_TYPE: ${{ inputs.bench_type }}
|
||||
run: |
|
||||
import os
|
||||
|
||||
if "${{ inputs.bench_type }}" == "both":
|
||||
inputs_command = os.environ["INPUTS_COMMAND"]
|
||||
inputs_op_flavor = os.environ["INPUTS_OP_FLAVOR"]
|
||||
inputs_bench_type = os.environ["INPUTS_BENCH_TYPE"]
|
||||
env_file = os.environ["GITHUB_ENV"]
|
||||
|
||||
split_command = inputs_command.replace(" ", "").split(",")
|
||||
split_op_flavor = inputs_op_flavor.replace(" ", "").split(",")
|
||||
|
||||
if inputs_bench_type == "both":
|
||||
bench_type = ["latency", "throughput"]
|
||||
else:
|
||||
bench_type = ["${{ inputs.bench_type }}", ]
|
||||
bench_type = [inputs_bench_type, ]
|
||||
|
||||
with open("${{ github.env }}", "a") as f:
|
||||
with open(env_file, "a") as f:
|
||||
for env_name, values_to_join in [
|
||||
("COMMAND", split_command),
|
||||
("OP_FLAVOR", split_op_flavor),
|
||||
|
||||
Reference in New Issue
Block a user