@@ -240,14 +240,14 @@ EnvironmentManager::EnvironmentManager()
240240}
241241
242242std::string
243- EnvironmentManager::ExtractIfNotExtracted (const std::string& env_source )
243+ EnvironmentManager::ExtractIfNotExtracted (const std::string& env_path )
244244{
245245 std::string canonical_env_path = [&] {
246246 char canonical_env_path[PATH_MAX + 1 ];
247- char * err = realpath (env_source .c_str (), canonical_env_path);
247+ char * err = realpath (env_path .c_str (), canonical_env_path);
248248 if (err == nullptr ) {
249249 throw PythonBackendException (
250- " Failed to get the canonical path for " + env_source + " ." );
250+ " Failed to get the canonical path for " + env_path + " ." );
251251 }
252252 return std::string (canonical_env_path);
253253 }();
@@ -271,34 +271,34 @@ EnvironmentManager::ExtractIfNotExtracted(const std::string& env_source)
271271 std::lock_guard<std::mutex> lk (mutex_);
272272
273273 time_t last_modified_time;
274- LastModifiedTime (env_source , &last_modified_time);
274+ LastModifiedTime (canonical_env_path , &last_modified_time);
275275
276- auto env_itr = env_map_.find (env_source );
276+ auto env_itr = env_map_.find (canonical_env_path );
277277 // Extract only if the env has not been extracted yet.
278278 if (env_itr == env_map_.end ()) {
279279 LOG_MESSAGE (
280280 TRITONSERVER_LOG_VERBOSE ,
281- (" Extracting Python execution env " + env_source ).c_str ());
281+ (" Extracting Python execution env " + canonical_env_path ).c_str ());
282282
283283 std::string dst_env_path =
284284 std::string (base_path_) + " /" + std::to_string (env_path_counter_);
285285 ++env_path_counter_;
286286
287- // Add the environment to the list of environments
287+ // Add the environment to the list of environments.
288288 env_itr = env_map_
289289 .try_emplace (
290- env_source, env_source, dst_env_path, last_modified_time)
290+ canonical_env_path, canonical_env_path, dst_env_path,
291+ last_modified_time)
291292 .first ;
292293 } else {
293294 Environment& env = env_itr->second ;
294295
295296 // Check if the environment has been modified and would
296- // need to be extracted again (or the current environment has no owners
297- // anymore).
297+ // need to be extracted again.
298298 if (env.LastModifiedTime () != last_modified_time) {
299299 LOG_MESSAGE (
300300 TRITONSERVER_LOG_VERBOSE ,
301- (" Re-extracting Python execution env " + env_source ).c_str ());
301+ (" Re-extracting Python execution env " + canonical_env_path ).c_str ());
302302 // Environment file has been updated. Need to clear
303303 // the previously extracted environment and extract
304304 // the environment to the same destination directory.
@@ -308,37 +308,39 @@ EnvironmentManager::ExtractIfNotExtracted(const std::string& env_source)
308308
309309 Environment& env = env_itr->second ;
310310
311- // Reference counter must be incremented on each ExtractIfNotExtracted call
311+ // Reference counter must be incremented on each ExtractIfNotExtracted call.
312312 env.IncrementRefCount ();
313313
314314 LOG_MESSAGE (
315315 TRITONSERVER_LOG_VERBOSE ,
316- (" Successfully extracted Python execution env " + env_source).c_str ());
316+ (" Successfully extracted Python execution env " + canonical_env_path)
317+ .c_str ());
317318
318- return env.Path ();
319+ return env.Destination ();
319320}
320321
321322void
322- EnvironmentManager::DropEnvironment (const std::string& env_source )
323+ EnvironmentManager::DropEnvironment (const std::string& canonical_env_path )
323324{
324325 LOG_MESSAGE (
325326 TRITONSERVER_LOG_VERBOSE ,
326- (" Trying to drop Python execution env " + env_source ).c_str ());
327+ (" Trying to drop Python execution env " + canonical_env_path ).c_str ());
327328
328329 std::lock_guard<std::mutex> lk (mutex_);
329330
330- auto env_itr = env_map_.find (env_source );
331+ auto env_itr = env_map_.find (canonical_env_path );
331332 if (env_itr != env_map_.end ()) {
332333 if (env_itr->second .DecrementRefCount () == 0 ) {
333334 env_map_.erase (env_itr);
334335 LOG_MESSAGE (
335336 TRITONSERVER_LOG_VERBOSE ,
336- (" Successfully dropped Python execution env " + env_source).c_str ());
337+ (" Successfully dropped Python execution env " + canonical_env_path)
338+ .c_str ());
337339 }
338340 } else {
339341 LOG_MESSAGE (
340342 TRITONSERVER_LOG_VERBOSE ,
341- (" The environment with the key '" + env_source +
343+ (" The environment with the key '" + canonical_env_path +
342344 " ' is not presented the env_map" )
343345 .c_str ());
344346 }
@@ -356,22 +358,24 @@ EnvironmentManager::~EnvironmentManager()
356358}
357359
358360EnvironmentManager::Environment::Environment (
359- const std::string& source, const std::string& path ,
361+ const std::string& source, const std::string& destination ,
360362 const time_t & last_modified_time)
361- : source_(source), path_(path), last_modified_time_(last_modified_time)
363+ : source_(source), destination_(destination),
364+ last_modified_time_(last_modified_time)
362365{
363366 Extract ();
364367}
365368
366369void
367370EnvironmentManager::Environment::Extract ()
368371{
369- int status = mkdir (path_.c_str (), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
372+ int status =
373+ mkdir (destination_.c_str (), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
370374 if (status != 0 ) {
371375 throw PythonBackendException (
372- " Failed to create environment directory for '" + path_ + " '." );
376+ " Failed to create environment directory for '" + destination_ + " '." );
373377 }
374- ExtractTarFile (source_, path_ );
378+ ExtractTarFile (source_, destination_ );
375379}
376380
377381void
@@ -385,7 +389,7 @@ EnvironmentManager::Environment::Update(const time_t& last_modified_time)
385389void
386390EnvironmentManager::Environment::Delete ()
387391{
388- RecursiveDirectoryDelete (path_ .c_str ());
392+ RecursiveDirectoryDelete (destination_ .c_str ());
389393}
390394
391395EnvironmentManager::Environment::~Environment ()
0 commit comments