Record library usage (e.g. which library is used)
(library_usage: str)
| 275 | |
| 276 | |
| 277 | def record_library_usage(library_usage: str): |
| 278 | """Record library usage (e.g. which library is used)""" |
| 279 | with _recorded_library_usages_lock: |
| 280 | if library_usage in _recorded_library_usages: |
| 281 | return |
| 282 | _recorded_library_usages.add(library_usage) |
| 283 | |
| 284 | if not _internal_kv_initialized(): |
| 285 | # This happens if the library is imported before ray.init |
| 286 | return |
| 287 | |
| 288 | # Only report lib usage for driver / ray client / workers. Otherwise, |
| 289 | # it can be reported if the library is imported from |
| 290 | # e.g., API server. |
| 291 | if ( |
| 292 | ray._private.worker.global_worker.mode == ray.SCRIPT_MODE |
| 293 | or ray._private.worker.global_worker.mode == ray.WORKER_MODE |
| 294 | or ray.util.client.ray.is_connected() |
| 295 | ): |
| 296 | _put_library_usage(library_usage) |
| 297 | |
| 298 | |
| 299 | def _put_pre_init_library_usages(): |
no test coverage detected
searching dependent graphs…