PubChemPy icon indicating copy to clipboard operation
PubChemPy copied to clipboard

Assay.from_aid().to_dict() fails for multiple AIDs

Open watplatt opened this issue 2 years ago • 0 comments

Assay.from_aid(2016).to_dict() fails. The reason is that a lot of 'comment' entries are absent altogether. The result is access to other records (e.g. 'target') is denied even if they do exist.

I can catch the exception, but it is a false failure (the 'target' may be there, but I can't get to it) for the records I want. Here's the report...

KeyError Traceback (most recent call last) Input In [36], in <cell line: 6>() 3 except Exception as x: 4 print(x) ----> 6 print(Assay.from_aid(2016).to_dict())

File ~/.conda/envs/myfastai/lib/python3.9/site-packages/pubchempy.py:1187, in Assay.to_dict(self, properties) 1185 if not properties: 1186 properties = [p for p in dir(Assay) if isinstance(getattr(Assay, p), property)] -> 1187 return {p: getattr(self, p) for p in properties}

File ~/.conda/envs/myfastai/lib/python3.9/site-packages/pubchempy.py:1187, in (.0) 1185 if not properties: 1186 properties = [p for p in dir(Assay) if isinstance(getattr(Assay, p), property)] -> 1187 return {p: getattr(self, p) for p in properties}

File ~/.conda/envs/myfastai/lib/python3.9/site-packages/pubchempy.py:1217, in Assay.comments(self) 1214 @property 1215 def comments(self): 1216 """Comments and additional information.""" -> 1217 return [comment for comment in self.record['assay']['descr']['comment'] if comment]

KeyError: 'comment'

watplatt avatar Jul 13 '23 21:07 watplatt