MCPcopy
hub / github.com/NVIDIA/TensorRT-LLM / run_cmd

Method run_cmd

tests/integration/defs/local_venv.py:102–133  ·  view source on GitHub ↗

Call on the command-line (can be used to run Python script files).

(self,
                args,
                caller=check_call,
                env=None,
                print_script=True,
                **kwargs)

Source from the content-addressed store, hash-verified

100 return self._run_internal(script, caller, print_script)
101
102 def run_cmd(self,
103 args,
104 caller=check_call,
105 env=None,
106 print_script=True,
107 **kwargs):
108 """Call <python-exe> <args> on the command-line (can be used to run Python script files)."""
109 if not os.path.exists(self.workspace):
110 os.makedirs(self.workspace, exist_ok=True)
111
112 call_args = [self._venv_bin] + args
113 if env:
114 new_env = copy.deepcopy(os.environ)
115 new_env.update(env)
116 else:
117 new_env = os.environ
118
119 if caller.__name__ == 'check_output':
120 try:
121 result = subprocess.run(call_args,
122 env=new_env,
123 check=True,
124 capture_output=True,
125 **kwargs)
126 return result.stdout.decode('utf-8')
127 except subprocess.CalledProcessError as e:
128 raise RuntimeError(f"Failed to run `{shlex.join(e.cmd)}`:\n"
129 f"Stdout: {e.stdout.decode()}\n"
130 f"Stderr: {e.stderr.decode()}\n")
131 else:
132 print(f"Start subprocess with {caller}({call_args}, env={new_env})")
133 return caller(call_args, env=new_env, **kwargs)
134
135 def install_packages(self, packages):
136 """Install Python packages by name."""

Callers 15

test_print_packagesFunction · 0.45
run_commandFunction · 0.45
venv_check_callFunction · 0.45
venv_check_outputFunction · 0.45
venv_mpi_check_callFunction · 0.45
venv_mpi_check_outputFunction · 0.45
convert_weightsFunction · 0.45
whisper_example_rootFunction · 0.45
opt_example_rootFunction · 0.45
llama_example_rootFunction · 0.45
gemma_example_rootFunction · 0.45

Calls 3

updateMethod · 0.45
runMethod · 0.45
decodeMethod · 0.45

Tested by 15

test_print_packagesFunction · 0.36
run_commandFunction · 0.36
whisper_example_rootFunction · 0.36
opt_example_rootFunction · 0.36
llama_example_rootFunction · 0.36
gemma_example_rootFunction · 0.36
gpt_example_rootFunction · 0.36
gptj_example_rootFunction · 0.36
glm_4_9b_example_rootFunction · 0.36
falcon_example_rootFunction · 0.36
internlm2_example_rootFunction · 0.36