T,hddlZddlZddlZddlmZddlmZddlmZddl m Z m Z m Z ddl mZmZddlmZddlmZdd lmZdd lmZmZeej4j7d j9j;Zgd ZiZ dd e!de!dzde!dzde!dzde"dzde!dedefdZ#dde"de$dzddfdZ%dZ&dd e!dzfdZ'y)N)Path)Any)Client) context_varsdeployutils) import_csvimport_tf_events)Run) SQLiteStorage)demo) TRACKIO_DIRTRACKIO_LOGO_DIRz version.txt)initlogfinishshowr r projectnamespace_id dataset_idconfigresumesettingsreturnc|tjd| | tdtj||\}}t j j}|B|tjddddd\}}}n|}t j j|t jj!t jj|k7rtd||!|tjd<td ||(td ttj |nBt#j$||td t"j&j)| t jj|d} |s t+|d } |dk(r6| td|t-j.|vrktd|d|d|dk(r(|R|t-j.|vr;td|n,|dk(r|%|t-j.|vrd}n tdt1||| ||} t j2j| | j4t7d<| S)a Creates a new Trackio project and returns a Run object. Args: project: The name of the project (can be an existing project to continue tracking or a new project to start tracking from scratch). name: The name of the run (if not provided, a default name will be generated). space_id: If provided, the project will be logged to a Hugging Face Space instead of a local directory. Should be a complete Space name like "username/reponame" or "orgname/reponame", or just "reponame" in which case the Space will be created in the currently-logged-in Hugging Face user's namespace. If the Space does not exist, it will be created. If the Space already exists, the project will be logged to it. dataset_id: If a space_id is provided, a persistent Hugging Face Dataset will be created and the metrics will be synced to it every 5 minutes. Specify a Dataset with name like "username/datasetname" or "orgname/datasetname", or "datasetname" (uses currently-logged-in Hugging Face user's namespace), or None (uses the same name as the Space but with the "_dataset" suffix). If the Dataset does not exist, it will be created. If the Dataset already exists, the project will be appended to it. config: A dictionary of configuration options. Provided for compatibility with wandb.init() resume: Controls how to handle resuming a run. Can be one of: - "must": Must resume the run with the given name, raises error if run doesn't exist - "allow": Resume the run if it exists, otherwise create a new run - "never": Never resume a run, always create a new one settings: Not used. Provided for compatibility with wandb.init() Nz* Warning: settings is not used. Provided for compatibility with wandb.init(). Please create an issue at: https://github.com/gradio-app/trackio/issues if you need a specific feature implemented.z8Must provide a `space_id` when `dataset_id` is provided.FT)show_apiinlinequietprevent_thread_lock show_errorz* Trackio project initialized: TRACKIO_DATASET_IDz:* Trackio metrics will be synced to Hugging Face Dataset: z* Trackio metrics logged to: z* View dashboard by going to: )r)verbosemustz*Must provide a run name when resume='must'zRun 'z' does not exist in project ''allowz* Resuming existing run: neverz2resume must be one of: 'must', 'allow', or 'never')urlrclientrrr)warningswarn ValueErrorr preprocess_space_and_dataset_idsrcurrent_servergetr launchsetcurrent_projectprintosenvironrprint_dashboard_instructionsrcreate_space_if_not_exists SPACE_URLformatrr get_runsr current_runrglobals) rrrrrrrr(_r)runs ,/fsx/qgallouedec/trackio/trackio/__init__.pyrrs0  Q J2STT AA(JWHj  % % ) ) +C {   $( IAsAC##'', $$((*2  ' ' + + - 8 /y9:  !/9BJJ+ , LZLY    1+? @  . .w 7  - -h C 01A1A1H1HRZ1H1[0\]   $$W- F U+  <IJ J }--g6 6uTF*GyPQRS S 7    (>(>w(G G -dV4 5 7    (>(>w(G GDMNN    C  %**GIh Jmetricsstepctjj}| td|j ||y)z Logs metrics to the current run. Args: metrics: A dictionary of metrics to log. step: The step number. If not provided, the step will be incremented automatically. Nz)Call trackio.init() before trackio.log().)rArB)rr;r/ RuntimeErrorr)rArBr>s r?rrzs@  " " & & (C {FGGGG  r@cztjj}| td|j y)z# Finishes the current run. Nz,Call trackio.init() before trackio.finish().)rr;r/rDr)r>s r?rrs2  " " & & (C {IJJJJLr@ctjddddtdz tg\}}}|r|dzn|}|r|d|zn|}td|t j |t jy) z Launches the Trackio dashboard. Args: project: The name of the project whose runs to show. If not provided, all projects will be shown and the user can select one. FTztrackio_logo_light.png)rrrr favicon_path allowed_paths/z ?project=z* Trackio UI launched at: N)r r0rr3 webbrowseropenrblock_except_in_notebook)rr=r( share_urlbase_url dashboard_urls r?rrs  %(@@'( AsI#,y3H8?H7)44XM &}o 67OOM" ""$r@)NNNNr'N)N)(r4r*rJpathlibrtypingr gradio_clientrtrackiorrrtrackio.importsr r trackio.runr trackio.sqlite_storager trackio.uir trackio.utilsrr__file__parentjoinpath read_textstrip __version____all__rstrdictrintrrrr@r?rds  //8078n##,,];EEGMMO M  !_ _ *_Dj_d _ 4K _  __ _DS4Z4"%#*%r@