mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-08 22:28:01 -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:
|
steps:
|
||||||
- name: Parse user inputs
|
- name: Parse user inputs
|
||||||
shell: python
|
shell: python
|
||||||
run: | # zizmor: ignore[template-injection] these env variables are safe
|
env:
|
||||||
split_command = "${{ inputs.command }}".replace(" ", "").split(",")
|
INPUTS_COMMAND: ${{ inputs.command }}
|
||||||
split_op_flavor = "${{ inputs.op_flavor }}".replace(" ", "").split(",")
|
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"]
|
bench_type = ["latency", "throughput"]
|
||||||
else:
|
else:
|
||||||
bench_type = ["${{ inputs.bench_type }}", ]
|
bench_type = [inputs_bench_type, ]
|
||||||
|
|
||||||
if "+" in "${{ inputs.params_type }}":
|
if "+" in inputs_params_type:
|
||||||
split_params_type= "${{ inputs.params_type }}".replace(" ", "").split("+")
|
split_params_type= inputs_params_type.replace(" ", "").split("+")
|
||||||
else:
|
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 [
|
for env_name, values_to_join in [
|
||||||
("COMMAND", split_command),
|
("COMMAND", split_command),
|
||||||
("OP_FLAVOR", split_op_flavor),
|
("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:
|
steps:
|
||||||
- name: Parse user inputs
|
- name: Parse user inputs
|
||||||
shell: python
|
shell: python
|
||||||
run: | # zizmor: ignore[template-injection] these env variables are safe
|
env:
|
||||||
split_command = "${{ inputs.command }}".replace(" ", "").split(",")
|
INPUTS_COMMAND: ${{ inputs.command }}
|
||||||
split_op_flavor = "${{ inputs.op_flavor }}".replace(" ", "").split(",")
|
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"]
|
bench_type = ["latency", "throughput"]
|
||||||
else:
|
else:
|
||||||
bench_type = ["${{ inputs.bench_type }}", ]
|
bench_type = [inputs_bench_type, ]
|
||||||
|
|
||||||
if "+" in "${{ inputs.params_type }}":
|
if "+" in inputs_params_type:
|
||||||
split_params_type= "${{ inputs.params_type }}".replace(" ", "").split("+")
|
split_params_type= inputs_params_type.replace(" ", "").split("+")
|
||||||
else:
|
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 [
|
for env_name, values_to_join in [
|
||||||
("COMMAND", split_command),
|
("COMMAND", split_command),
|
||||||
("OP_FLAVOR", split_op_flavor),
|
("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:
|
steps:
|
||||||
- name: Parse user inputs
|
- name: Parse user inputs
|
||||||
shell: python
|
shell: python
|
||||||
run: | # zizmor: ignore[template-injection] these env variables are safe
|
env:
|
||||||
split_command = "${{ inputs.command }}".replace(" ", "").split(",")
|
INPUTS_COMMAND: ${{ inputs.command }}
|
||||||
split_op_flavor = "${{ inputs.op_flavor }}".replace(" ", "").split(",")
|
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"]
|
bench_type = ["latency", "throughput"]
|
||||||
else:
|
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 [
|
for env_name, values_to_join in [
|
||||||
("COMMAND", split_command),
|
("COMMAND", split_command),
|
||||||
("OP_FLAVOR", split_op_flavor),
|
("OP_FLAVOR", split_op_flavor),
|
||||||
|
|||||||
Reference in New Issue
Block a user