Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Converting from kerchunk to CFA: fix or document behaviour

未關閉
#945 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
python
領域
data

研究方向

從 cf/test/test_kerchunk.py 開始,使用 kerchunk 物件透過 cf.write 重現 CFA 寫入。追蹤 cfdm/read_write/netcdf/netcdfwrite.py 中的失敗,尤其是 _cfa_fragment_array_variables 及其對 urisplit 的呼叫,以判斷是否能支援 FSMap 輸入。完成的標準是轉換測試通過,或記錄說明不支援此轉換。

由索引模型根據 Issue 內容生成。

描述

aggregation kerchunk

Regarding our read/write formats support, we yesterday realised the case of going from (newly-supported in v3.20!) kerchunk to CFA, i.e. reading kerchunk and attempting to write it out as CFA, may not work on paper - and indeed when tetsing this I get a TypeError: expected string or bytes-like object, got 'FSMap' error, for example by adding a few lines to a relevant test to request a CFA-format write of read-in kerchunk, namely:

diff --git a/cf/test/test_kerchunk.py b/cf/test/test_kerchunk.py
index b37d09718d..98a9b89968 100644
--- a/cf/test/test_kerchunk.py
+++ b/cf/test/test_kerchunk.py
@@ -75,7 +75,10 @@ class read_writeTest(unittest.TestCase):
 
         fs = fsspec.filesystem("reference", fo=d)
         kerchunk = fs.get_mapper()
-        self.assertEqual(len(cf.read(kerchunk)), 1)
+        k = cf.read(kerchunk)
+        self.assertEqual(len(k), 1)
+        print("Attempting kerchunk -> CFA")
+        cf.write(k, "kerchunk_to_cfa.cfa", cfa="field")
 
     def test_read_bytes(self):
         """Test cf.read with a Kerchunk raw bytes representation."""

I see:

======================================================================
ERROR: test_read_dict (__main__.read_writeTest.test_read_dict)
Test cf.read with an Kerchunk dictionary.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/slb93/git-repos/cf-python/cf/test/test_kerchunk.py", line 81, in test_read_dict
    cf.write(k, "kerchunk_to_cfa.cfa", cfa="field")
  File "/home/slb93/git-repos/cfdm/cfdm/read_write/write.py", line 936, in __new__
    netcdf.write(
  File "/home/slb93/git-repos/cfdm/cfdm/decorators.py", line 171, in verbose_override_wrapper
    return method_with_verbose_kwarg(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/slb93/git-repos/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 5952, in write
    self._file_io_iteration(
  File "/home/slb93/git-repos/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 6230, in _file_io_iteration
    self._write_field_or_domain(f)
  File "/home/slb93/git-repos/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 4746, in _write_field_or_domain
    self._write_netcdf_variable(
  File "/home/slb93/git-repos/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 3310, in _write_netcdf_variable
    cfa = self._cfa_fragment_array_variables(data, cfvar)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/slb93/git-repos/cfdm/cfdm/read_write/netcdf/netcdfwrite.py", line 7014, in _cfa_fragment_array_variables
    uri = urisplit(dataset_name)
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/slb93/miniconda3/envs/cf-env-312-numpy2/lib/python3.12/site-packages/uritools/__init__.py", line 545, in urisplit
    return result(*result.RE.match(uristring).groups())
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'FSMap'

so there's at least an immediate logical issue to work through relating to type expectations for this case, but there we should work out whether the case can be supported - if so how much further work/logic is needed - and if not feasible to support soon we should document that this case doesn't (yet) work.

主要語言
Python
星號
151
分支
23
平均合併
1 天 2 小時
30 天內合併 PR
1

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

NCAS-CMS/cf-python 的其他 Issue

查看 NCAS-CMS/cf-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。