
    5i                     Z    d Z ddlmZmZmZmZ ddlZddlZddlm	Z	 ddl
mZ d Zd	 Zd
 Zy)a	  
Accessing App-Specific Containers
+++++++++++++++++++++++++++++++++

Apps have associated resource containers and project cache containers.
To easily access these, the following utility functions are provided.
These functions are meant to be called only by a job.
    )print_functionunicode_literalsdivisionabsolute_importN   )DXError   )find_one_data_objectc                  T   d| v rt        d      t        j                  t        d      dt        j                  vrdt        j                  vrt        d      t        j                  j                  dt        j                  j                  d            | d<   d| d<   t        d	i | S )
a  
    :param kwargs: keyword args for :func:`~dxpy.bindings.search.find_one_data_object`, with the exception of "project"
    :raises: :exc:`~dxpy.exceptions.DXError` if "project" is given, if this is called with dxpy.JOB_ID not set, or if "DX_RESOURCES_ID" or "DX_PROJECT_CONTEXT_ID" is not found in the environment variables
    :returns: None if no matching object is found; otherwise returns a dxpy object handler for that class of object

    Searches for a data object in the app resources container matching the given keyword arguments.  If found, the
    object will be cloned into the running job's workspace container, and the handler for it will be returned. If the
    app resources container ID is not found in DX_RESOURCES_ID, falls back to looking in the current project.

    Example::

        @dxpy.entry_point('main')
        def main(*args, **kwargs):
            x = load_app_resource(name="Indexed genome", classname='file')
            dxpy.download_dxfile(x)
    projectUnexpected kwarg: "project"Not called by a jobDX_RESOURCES_IDDX_PROJECT_CONTEXT_IDz-App resources container ID could not be foundTreturn_handler )r   dxpyJOB_IDosenvirongetr
   )kwargss    /home/marpiech/ifpan-abm-pgxpred/analysis/marpiech-gwas-test/venv/lib/python3.12/site-packages/dxpy/bindings/dxapp_container_functions.pyload_app_resourcer   "   s    $ F344{{+,,

*/Fbjj/XEFF

'8"**..I`:abF9#F)&))    c                  8   d| v rt        d      t        j                  t        d      dt        j                  vrt        d      t        j                  j                  d      | d<   d| d<   t        d	i | }|y|j                  t        j                        S )
a  
    :param kwargs: keyword args for :func:`~dxpy.bindings.search.find_one_data_object`, with the exception of "project"
    :raises: :exc:`~dxpy.exceptions.DXError` if "project" is given, if this is called with dxpy.JOB_ID not set, or if "DX_PROJECT_CACHE_ID" is not found in the environment variables
    :returns: None if no matching object is found; otherwise returns a dxpy object handler for that class of object

    Searches for a data object in the project cache container matching
    the given keyword arguments.  If found, the object will be cloned
    into the running job's workspace container, and the handler for it
    will be returned.

    Example::

        @dxpy.entry_point('main')
        def main(*args, **kwargs):
            x = load_from_cache(name="Indexed genome", classname='file')
            if x is None:
                x = compute_result(*args)
                save_to_cache(x)
    r   r   Nr   DX_PROJECT_CACHE_IDSProject cache ID could not be found in the environment variable DX_PROJECT_CACHE_IDTr   r   )	r   r   r   r   r   r   r
   cloneWORKSPACE_ID)r   cached_objects     r   load_from_cacher"   @   s    * F344{{+,,BJJ.kll

'<=F9#F(262Mt0011r   c                     t         j                  t        d      dt        j                  vrt        d      | j                  t        j                  j                  d             y)a(  
    :param dxobject: a dxpy object handler for an object to save to the cache
    :raises: :exc:`~dxpy.exceptions.DXError` if this is called with dxpy.JOB_ID not set, or if "DX_PROJECT_CACHE_ID" is not found in the environment variables

    Clones the given object to the project cache.

    Example::

        @dxpy.entry_point('main')
        def main(*args, **kwargs):
            x = load_from_cache(name="Indexed genome", classname='file')
            if x is None:
                x = compute_result(*args)
                save_to_cache(x)
    Nr   r   r   )r   r   r   r   r   r   r   )dxobjects    r   save_to_cacher%   g   sL    " {{+,,BJJ.kllNN2::>>"789r   )__doc__
__future__r   r   r   r   r   r   
exceptionsr   searchr
   r   r"   r%   r   r   r   <module>r*      s/   " S R 	    (*<$2N:r   