@@ -33,8 +33,8 @@ def get_default_container_name():
33
33
class ContainerRuntimeError (RuntimeError ):
34
34
"""An error raised when running a container fails."""
35
35
36
- def __init__ (self , * , error , name , cmd , returncode , traceback = None ):
37
- self .name = name
36
+ def __init__ (self , * , error , args , cmd , returncode , traceback = None ):
37
+ self .args = args
38
38
self .cmd = cmd
39
39
self .returncode = returncode
40
40
self .traceback = traceback
@@ -87,8 +87,16 @@ def get_default_container_run_args(
87
87
)
88
88
89
89
90
+ def get_default_log_level_args (logger ):
91
+ log_level_str = str (logging .getLevelName (logger .getEffectiveLevel ())).lower ()
92
+ logger .debug ("computed effective logging level: %s" , log_level_str )
93
+ return [
94
+ "--log-level" ,
95
+ log_level_str ,
96
+ ]
97
+
98
+
90
99
def run_container_operation (
91
- name : str ,
92
100
args : Iterable [str ],
93
101
json_loads : Callable = json .loads ,
94
102
tmpfs_size_mb : int = DEFAULT_CONTAINER_TMPFS_SIZE_MB ,
@@ -100,8 +108,6 @@ def run_container_operation(
100
108
101
109
Parameters
102
110
----------
103
- name
104
- The name of the operation.
105
111
args
106
112
The arguments to pass to the container.
107
113
json_loads
@@ -131,18 +137,11 @@ def run_container_operation(
131
137
else :
132
138
mnt_args = []
133
139
134
- log_level_str = str (logging .getLevelName (logger .getEffectiveLevel ())).lower ()
135
- logger .debug ("computed effective logging level: %s" , log_level_str )
136
-
137
140
cmd = [
138
141
* get_default_container_run_args (tmpfs_size_mb = tmpfs_size_mb ),
139
142
* mnt_args ,
140
143
get_default_container_name (),
141
- "conda-forge-feedstock-ops-container" ,
142
- name ,
143
144
* args ,
144
- "--log-level" ,
145
- log_level_str ,
146
145
]
147
146
res = subprocess .run (
148
147
cmd ,
@@ -153,10 +152,10 @@ def run_container_operation(
153
152
# we handle this ourselves to customize the error message
154
153
if res .returncode != 0 :
155
154
raise ContainerRuntimeError (
156
- error = f"Error running { name } in container - return code { res .returncode } :"
155
+ error = f"Error running ' { ' ' . join ( args ) } ' in container - return code { res .returncode } :"
157
156
f"\n cmd: { pprint .pformat (cmd )} "
158
157
f"\n output: { pprint .pformat (res .stdout )} " ,
159
- name = name ,
158
+ args = args ,
160
159
cmd = pprint .pformat (cmd ),
161
160
returncode = res .returncode ,
162
161
)
@@ -165,10 +164,10 @@ def run_container_operation(
165
164
ret = json_loads (res .stdout )
166
165
except json .JSONDecodeError :
167
166
raise ContainerRuntimeError (
168
- error = f"Error running { name } in container - JSON could not parse stdout:"
167
+ error = f"Error running ' { ' ' . join ( args ) } ' in container - JSON could not parse stdout:"
169
168
f"\n cmd: { pprint .pformat (cmd )} "
170
169
f"\n output: { pprint .pformat (res .stdout )} " ,
171
- name = name ,
170
+ args = args ,
172
171
cmd = pprint .pformat (cmd ),
173
172
returncode = res .returncode ,
174
173
)
@@ -182,8 +181,8 @@ def run_container_operation(
182
181
.decode ("unicode_escape" )
183
182
)
184
183
raise ContainerRuntimeError (
185
- error = f"Error running { name } in container - error { ret ['error' ].split ('(' )[0 ]} raised:\n { ret_str } " ,
186
- name = name ,
184
+ error = f"Error running ' { ' ' . join ( args ) } ' in container - error { ret ['error' ].split ('(' )[0 ]} raised:\n { ret_str } " ,
185
+ args = args ,
187
186
cmd = pprint .pformat (cmd ),
188
187
returncode = res .returncode ,
189
188
traceback = ret ["traceback" ]
0 commit comments