Skip to content

Commit 2d251a3

Browse files
authored
Merge pull request #2135 from MicrosoftDocs/repo_sync_working_branch
Confirm merge from repo_sync_working_branch to main to sync with https://github.com/MicrosoftDocs/azure-ai-docs (branch main)
2 parents 3fd2ed9 + 19f608c commit 2d251a3

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

articles/machine-learning/how-to-log-view-metrics.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,24 +172,41 @@ import mlflow
172172
173173
mlflow.config.enable_async_logging()
174174
```
175+
It is recommended to use above global flag when you want to enable asynchronous logging of metrics throughout your code
176+
and/or you are using some wrapper library that wraps mlflow for logging actual metrics.
175177
176178
The same property can be set, using an environment variable:
177179
178180
```python
179181
export MLFLOW_ENABLE_ASYNC_LOGGING=True
180182
```
181183
182-
To log specific metrics asynchronously, use the MLflow logging API as you typically would, but add the extra parameter `synchronous=False`.
184+
To log specific metrics asynchronously, use the MLflow logging API as you typically would, but add the extra parameter `synchronous=False`.
185+
186+
Setting up `synchronous=False` is optional if you set global flag to log in asynchronous way using `mlflow.enable_async_logging()`.
183187
184188
```python
185189
import mlflow
186190
187191
with mlflow.start_run():
188192
# (...)
193+
# when global async logging flag is not set using - mlflow.enable_async_logging()
189194
mlflow.log_metric("metric1", 9.42, synchronous=False)
190195
# (...)
191196
```
192197
198+
```python
199+
import mlflow
200+
# Set global async logging flag
201+
mlflow.enable_async_logging()
202+
203+
with mlflow.start_run():
204+
# (...)
205+
# You can use all fluent syntax or MlflowClient APIs and all of them will log metrics in asynchronous fashion.
206+
mlflow.log_metric("metric1", 9.42)
207+
# (...)
208+
```
209+
193210
When you use `log_metric(synchronous=False)`, control is automatically returned to the caller once the operation is accepted; however, the value is not available for reading inmediately. Asynchronous logging of metrics does guarantee order and they are persisted with the timestamp of when they were logged.
194211
195212
> [!IMPORTANT]
@@ -225,6 +242,7 @@ with mlflow.start_run() as current_run:
225242
run_operation = mlflow_client.log_batch(
226243
run_id=current_run.info.run_id,
227244
metrics=metrics_arr,
245+
#Optional when global async logging flag is set using - mlflow.enable_async_logging()
228246
synchronous=False,
229247
)
230248
```

0 commit comments

Comments
 (0)