首页 > 解决方案 > 摄入缓存指定文件名/位置

问题描述

我正在尝试使用intakeintake-xarray打开和存储远程文件。我在这里有一个最小化的目录文件:

/isibhv/projects/paleo_pool/boundary_conditions/ice_sheet_reconstructions/ice_sheet_reconstructions.yaml

它看起来像这样:

metadata:
  version: 1
sources:
  glac1d:
    description: The GLAC-1D Reconstruction 
    driver: netcdf
    args:
        urlpath: "https://sharebox.lsce.ipsl.fr/index.php/s/yfuUw91ruuJXroC/download?path=%2F&files=TOPicemsk.GLACD26kN9894GE90227A6005GGrBgic.nc"
    cache_dir: "{{ CATALOG_DIR }}/glac1d"
    cache: 
        - argkey: urlpath
          type: file

我可以在 Python 中打开文件:

import intake
cat = intake.open_catalog("ice_sheet_reconstructions.yaml")
ds = cat.glac1d.read()

这一切都非常有效;我得到了我期望的文件。但是,缓存没有显示在我期望的位置。我猜想在下面创建了一个新文件夹:

/isibhv/projects/paleo_pool/boundary_conditions/ice_sheet_reconstructions/glac1d

相反,我在我的主目录中得到了一些东西。

我是否错误地指定了缓存目录?

作为第二个问题:是否可以直接指定缓存文件在保存时应如何调用?

谢谢!保罗

标签: intake

解决方案


缓存的位置由配置指定,该配置通常是一个 YAML 文件~/.intake/conf.yaml(键“cache_dir”),但可以根据INTAKE_CONF(_FILE)环境变量或源的元数据,键“catalog_dir”(<- 这可能不正确?)。特殊值“catdir”表示“在目录所在的目录中”。

然而

随着缓存fsspec的出现,以下将是可能的:

sources:
  glac1d:
    description: The GLAC-1D Reconstruction 
    driver: netcdf
    args:
        urlpath: "filecache://sharebox.lsce.ipsl.fr/index.php/s/yfuUw91ruuJXroC/download?path=%2F&files=TOPicemsk.GLACD26kN9894GE90227A6005GGrBgic.nc"
        storage_options:
            target_protocol: https
            cache_storage: "{{ CATALOG_DIR }}/glac1d"

不幸的是,intake-xarray 中还没有所需的更改。


推荐阅读