You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Include a detailed description of the bug or suggestion
Output of intake_esm.show_versions()
Minimal, self-contained copy-pastable example that generates the issue if possible. Please be concise with code posted. See guidelines below on how to provide a good bug report:
I am trying to pass a python re.compile object for one of the column entries in an intake catalog search following the example in the code comments. However, the search method expects values to be iterables in the query dict, and throws an error when trying to resolve the re.compile object.
What I Did
forcase_name, case_dincase_dict.items():
path_regex=re.compile(r'({})'.format(case_name)). # Search for the case_name group in the path entriesfreq=case_d.varlist.T.frequencyforvincase_d.varlist.iter_vars():
cat_subset=cat.search(activity_id=case_d.convention,
standard_name=v.standard_name,
frequency=freq,
realm=v.realm,
path=path_regex
)
The path_regex object passed to catalog _search.search method:
Thus, values.pattern seems like it is what the search method should be using in the for value in valuesloop if values is an re.compile object
Stack trace
File "/Users/j/micromamba/envs/_MDTF_base/lib/python3.11/site-packages/pydantic/deprecated/decorator.py", line 55, in wrapper_function
return vd.call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/j/micromamba/envs/_MDTF_base/lib/python3.11/site-packages/pydantic/deprecated/decorator.py", line 150, in call
return self.execute(m)
^^^^^^^^^^^^^^^
File "/Users/j/micromamba/envs/_MDTF_base/lib/python3.11/site-packages/pydantic/deprecated/decorator.py", line 222, in execute
return self.raw_function(**d, **var_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/j/micromamba/envs/_MDTF_base/lib/python3.11/site-packages/intake_esm/core.py", line 393, in search
esmcat_results = self.esmcat.search(require_all_on=require_all_on, query=query)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/j/micromamba/envs/_MDTF_base/lib/python3.11/site-packages/intake_esm/cat.py", line 385, in search
results = search(
^^^^^^^
File "/Users/j/micromamba/envs/_MDTF_base/lib/python3.11/site-packages/intake_esm/_search.py", line 46, in search
for value in values:
TypeError: 're.Pattern' object is not iterable
Version information: output of intake_esm.show_versions()
Paste the output of intake_esm.show_versions() here:
@wrongkindofdoctor - can you try passing it as a list? Sorry for the delayed response here.
ex.
forcase_name, case_dincase_dict.items():
path_regex=re.compile(r'({})'.format(case_name)). # Search for the case_name group in the path entriesfreq=case_d.varlist.T.frequencyforvincase_d.varlist.iter_vars():
cat_subset=cat.search(activity_id=case_d.convention,
standard_name=v.standard_name,
frequency=freq,
realm=v.realm,
path=[path_regex]
)
@mgrover1 sorry for the late response. I just got around to testing passing the re.compile object as a list to cat.search, and this resolves the issue. Thanks for your help!
Here's a quick checklist in what to include:
Include a detailed description of the bug or suggestion
Output of
intake_esm.show_versions()
Minimal, self-contained copy-pastable example that generates the issue if possible. Please be concise with code posted. See guidelines below on how to provide a good bug report:
Description
I am trying to pass a python
re.compile
object for one of the column entries in an intake catalog search following the example in the code comments. However, the search method expects values to be iterables in thequery
dict, and throws an error when trying to resolve the re.compile object.What I Did
The path_regex object passed to catalog
_search.search
method:path_regex has the following attributes:
Thus,
values.pattern
seems like it is what the search method should be using in thefor value in values
loop ifvalues
is an re.compile objectStack trace
Version information: output of
intake_esm.show_versions()
Paste the output of
intake_esm.show_versions()
here:The text was updated successfully, but these errors were encountered: