Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement callback function and add
iter
to logs
<p dir="auto">We use this e.g. to implement a logging callback for logging to mlflow. An example snippet</p> <div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia> using PythonCall julia> mlflow = pyimport("mlflow") julia> mlflow.set_tracking_uri("http://mycloud-nixos:8095") julia> pywith(mlflow.start_run()) do _ for iter in 1:10 mlflow.log_metric("foo", 1*iter, step=iter) mlflow.log_metric("bar", 2) end end"><pre class="notranslate"><span class="pl-s1">julia</span><span class="pl-c1">></span> <span class="pl-s1">using</span> <span class="pl-v">PythonCall</span> <span class="pl-s1">julia</span><span class="pl-c1">></span> <span class="pl-s1">mlflow</span> <span class="pl-c1">=</span> <span class="pl-en">pyimport</span>(<span class="pl-s">"mlflow"</span>) <span class="pl-s1">julia</span><span class="pl-c1">></span> <span class="pl-s1">mlflow</span>.<span class="pl-en">set_tracking_uri</span>(<span class="pl-s">"http://mycloud-nixos:8095"</span>) <span class="pl-s1">julia</span><span class="pl-c1">></span> <span class="pl-en">pywith</span>(<span class="pl-s1">mlflow</span>.<span class="pl-en">start_run</span>()) <span class="pl-s1">do</span> <span class="pl-s1">_</span> <span class="pl-k">for</span> <span class="pl-s1">iter</span> <span class="pl-c1">in</span> <span class="pl-c1">1</span>:<span class="pl-c1">10</span> <span class="pl-s1">mlflow</span>.<span class="pl-en">log_metric</span>(<span class="pl-s">"foo"</span>, <span class="pl-c1">1</span><span class="pl-c1">*</span><span class="pl-s1">iter</span>, <span class="pl-s1">step</span><span class="pl-c1">=</span><span class="pl-s1">iter</span>) <span class="pl-s1">mlflow</span>.<span class="pl-en">log_metric</span>(<span class="pl-s">"bar"</span>, <span class="pl-c1">2</span>) <span class="pl-s1">end</span> <span class="pl-s1">end</span></pre></div>
- Loading branch information