Ë
    (†^i  ã                  ó  — d dl mZ d dlmZ d dlmZ d dlZd dlZd dlZd dlZd dl	m
Z
 d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ dZdZe G d„ d«      «       Z e
g d¢dd¬«      ddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Zy)é    )Úannotations)Úasdict)Ú	dataclassN)Úconvert_positional_args)ÚArtifactStore)ÚBaseStorage)ÚStudy)ÚFrozenTrial)ÚTrialz
artifacts:zapplication/octet-streamc                  ó:   — e Zd ZU dZded<   ded<   ded<   ded<   y)	ÚArtifactMetaaþ  Meta information for an artifact.

    .. note::
        All the artifact meta linked to a study or trial can be listed by
        :func:`~optuna.artifacts.get_all_artifact_meta`.
        The artifact meta can be used for :func:`~optuna.artifacts.download_artifact`.

    Args:
        artifact_id:
            The identifier of the artifact.
        filename:
            The artifact file name used for the upload.
        mimetype:
            A MIME type of the artifact.
            If not specified, the MIME type is guessed from the file extension.
        encoding:
            An encoding of the artifact, which is suitable for use as a Content-Encoding header,
            e.g., gzip. If not specified, the encoding is guessed from the file extension.
    ÚstrÚartifact_idÚfilenameÚmimetypeú
str | NoneÚencodingN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© ó    úY/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/optuna/artifacts/_upload.pyr   r      s   … ñð( ÓØƒMØƒMØÔr   r   )Ústudy_or_trialÚ	file_pathÚartifact_storez4.0.0z6.0.0)Úprevious_positional_arg_namesÚdeprecated_versionÚremoved_version)Ústorager   r   c           	     ó  — t         j                  j                  |«      }t        |t        «      r|€|j
                  }nt        |t        «      r|€|j                  }|€t        d«      ‚t        t        j                  «       «      }t        j                  |«      \  }}	t        |||xs
 |xs t        |xs |	¬«      }
t         |z   }t        |t        t"        f«      r<|j$                  }|j'                  ||t)        j*                  t-        |
«      «      «       n;|j.                  }|j1                  ||t)        j*                  t-        |
«      «      «       t3        |d«      5 }| j5                  ||«       ddd«       |S # 1 sw Y   |S xY w)as  Upload an artifact to the artifact store.

    Args:
        artifact_store:
            An artifact store.
        file_path:
            A path to the file to be uploaded.
        study_or_trial:
            A :class:`~optuna.trial.Trial` object, a :class:`~optuna.trial.FrozenTrial`, or
            a :class:`~optuna.study.Study` object.
        storage:
            A storage object. This argument is required only if ``study_or_trial`` is
            :class:`~optuna.trial.FrozenTrial`.
        mimetype:
            A MIME type of the artifact. If not specified, the MIME type is guessed from the file
            extension.
        encoding:
            An encoding of the artifact, which is suitable for use as a ``Content-Encoding``
            header (e.g. gzip). If not specified, the encoding is guessed from the file extension.

    Returns:
        An artifact ID.
    Nz$storage is required for FrozenTrial.)r   r   r   r   Úrb)ÚosÚpathÚbasenameÚ
isinstancer   r"   r	   Ú_storageÚ
ValueErrorr   ÚuuidÚuuid4Ú	mimetypesÚ
guess_typer   ÚDEFAULT_MIME_TYPEÚARTIFACTS_ATTR_PREFIXr
   Ú	_trial_idÚset_trial_system_attrÚjsonÚdumpsr   Ú	_study_idÚset_study_system_attrÚopenÚwrite)r   r   r   r"   r   r   r   r   Úguess_mimetypeÚguess_encodingÚartifactÚattr_keyÚtrial_idÚstudy_idÚfs                  r   Úupload_artifactr@   2   sP  € ôL w‰w×Ñ 	Ó*€Hä.¤%Ô(¨W¨_Ø ×(Ñ(‰Ü	N¤EÔ	*¨w¨Ø ×)Ñ)ˆà€ÜÐ?Ó@Ð@ä”d—j‘j“lÓ#€KÜ%.×%9Ñ%9¸(Ó%CÑ"€NNÜØØØÒ@˜^Ò@Ô/@ØÒ+˜^ô	€Hô % {Ñ2€HÜ.¤5¬+Ð"6Ô7Ø!×+Ñ+ˆØ×%Ñ% h°¼$¿*¹*ÄVÈHÓEUÓ:VÕWà!×+Ñ+ˆØ×%Ñ% h°¼$¿*¹*ÄVÈHÓEUÓ:VÔWä	ˆi˜Ó	ð - !Ø×Ñ˜[¨!Ô,÷-àÐ÷-àÐús   Å E=Å=F)r   r   r   r   r   zTrial | FrozenTrial | Studyr"   zBaseStorage | Noner   r   r   r   Úreturnr   )Ú
__future__r   Údataclassesr   r   r3   r-   r%   r+   Úoptuna._convert_positional_argsr   Úoptuna.artifacts._protocolr   Úoptuna.storagesr   Úoptuna.studyr	   Úoptuna.trialr
   r   r0   r/   r   r@   r   r   r   ú<module>rI      sÄ   ðÝ "å Ý !Û Û Û 	Û å CÝ 4Ý 'Ý Ý $Ý ð %Ð Ø.Ð ð ÷ð ó ðñ6 Ú"SØØôð #'ØØñ=à!ð=ð ð=ð 0ð	=ð
  ð=ð ð=ð ð=ð 	ò=óñ
=r   