Converting from kerchunk to CFA: fix or document behaviour
還沒有人認領這個 Issue。
評估
研究方向
從 cf/test/test_kerchunk.py 開始,使用 kerchunk 物件透過 cf.write 重現 CFA 寫入。追蹤 cfdm/read_write/netcdf/netcdfwrite.py 中的失敗,尤其是 _cfa_fragment_array_variables 及其對 urisplit 的呼叫,以判斷是否能支援 FSMap 輸入。完成的標準是轉換測試通過,或記錄說明不支援此轉換。
由索引模型根據 Issue 內容生成。
描述
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 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
NCAS-CMS/cf-python 的其他 Issue
-
installation
難度 4/5 3-5 天 新手友好度 45/100
-
Attempt at unsupported conservative 3D mesh regridding可能重新可做 @sadielbartholomew 於 43 天前認領,目前沒有進行中的 PR。 未關閉bug?
-
bug
難度 3/5 1-2 天 新手友好度 45/100
-
API review (4.0.0) documentation
難度 4/5 3-5 天 新手友好度 48/100
-
enhancement xarray
難度 4/5 3-5 天 新手友好度 48/100
查看 NCAS-CMS/cf-python 的全部 Issue
相似的 Issue
-
Python Volcengine provider returns failures instead of raising them可能已有人在做 @Ricardo-M-L 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 79/100
agent-infra/sandbox#248 ·
-
Textractor leaves empty temporary files when remote retrieval fails可能已有人在做 @HuaTNA 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
test(bm_generation): pin the learning parameters and CPU sync shortcut可能已有人在做 @iloveeyjafjalla 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
qboson/kaiwu-pytorch-plugin#1341 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
elder-plinius/V3R1T4S#625 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆