ó
    -j†iI  ã                  ó  • S SK Jr  S SKJr  S SKJr  S SKrS SKrS SKrS SKJ	r	  S SK
r
S SKJr  S SKJr  S SKJr  S S	KJr  \	(       a  S S
KJr  S SKJr  SrSr\ " S S5      5       r\" / SQSSS9SSSS.             SS jj5       rg)é    )Úannotations)Úasdict)Ú	dataclassN)ÚTYPE_CHECKING)Úconvert_positional_args)ÚStudy)ÚFrozenTrial)ÚTrial)ÚArtifactStore)ÚBaseStoragez
artifacts:zapplication/octet-streamc                  óB   • \ rS rSr% SrS\S'   S\S'   S\S'   S\S'   S	rg
)ÚArtifactMetaé   a¾  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Úencoding© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Ú__static_attributes__r   ó    ÚR/home/james-whalen/.local/lib/python3.13/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           	     óZ  • [         R                  R                  U5      n[        U[        5      (       a  Uc  UR
                  nO$[        U[        5      (       a  Uc  UR                  nUc  [        S5      e[        [        R                  " 5       5      n[        R                  " U5      u  p‰[        UUU=(       d    U=(       d    [        U=(       d    U	S9n
[         U-   n[        U[        ["        45      (       a<  UR$                  nUR'                  XË[(        R*                  " [-        U
5      5      5        O;UR.                  nUR1                  XÛ[(        R*                  " [-        U
5      5      5        [3        US5       nU R5                  X~5        SSS5        U$ ! , (       d  f       U$ = f)a#  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_artifactrD   5   sO  € ôL w‰w×Ñ 	Ó*€Hä.¤%×(Ñ(¨W©_Ø ×(Ñ(‰Ü	N¤E×	*Ñ	*¨w©Ø ×)Ñ)ˆàÜÐ?Ó@Ð@ä”d—j’j“lÓ#€KÜ%.×%9Ò%9¸(Ó%CÑ"€NÜØØØ×@˜^×@Ô/@Ø×+˜^ñ	€Hô % {Ñ2€HÜ.¤5¬+Ð"6×7Ñ7Ø!×+Ñ+ˆØ×%Ñ% h¼$¿*º*ÄVÈHÓEUÓ:VÕWà!×+Ñ+ˆØ×%Ñ% h¼$¿*º*ÄVÈHÓEUÓ:VÔWä	ˆi˜Ô	 !Ø×Ñ˜[Ô,÷ 
àÐ÷ 
Ô	àÐús   Å?FÆ
F*)r"   r   r!   r   r    zTrial | FrozenTrial | Studyr&   zBaseStorage | Noner   r   r   r   Úreturnr   )Ú
__future__r   Údataclassesr   r   r7   r1   r)   Útypingr   r/   Úoptuna._convert_positional_argsr   Úoptuna.studyr   Úoptuna.trialr	   r
   Úoptuna.artifacts._protocolr   Úoptuna.storagesr   r4   r3   r   rD   r   r   r   Ú<module>rN      sÊ   ðÝ "å Ý !Û Û Û 	Ý  Û å CÝ Ý $Ý ö Ý8Ý+à$Ð Ø.Ð ð ÷ð ó ðñ6 Ú"SØØñð #'ØØñ=à!ð=ð ð=ð 0ð	=ð
  ð=ð ð=ð ð=ð 	ô=óñ
=r   