Today I tried to run the same code as yesterday, but I got
DALServiceError: 401 Client Error: Unauthorized for url: https://data.lsst.cloud/api/tap/sync
I have:
Get an instance of the TAP service
service = get_tap_service()
assert service is not None
assert service.baseurl == “https://data.lsst.cloud/api/tap”
and using the same query as before:
For more detailed analysis of results, converting
to a pandas dataframe is often very useful (“df” stands for “dataframe”)
df = service.search(query, maxrec=max_rec).to_table().to_pandas()
Use an assertion to make sure we got the correct number of results.
assert len(df) == 15670
len(df.coord_ra)
which gives me:
E19 Traceback (most recent call last)
File /opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-4.0.0/lib/python3.10/site-packages/pyvo/dal/query.py:242, in DALQuery.execute_votable(self, post)
241 try:
→ 242 return votableparse(self.execute_stream(post=post).read)
243 except Exception as e:
File /opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-4.0.0/lib/python3.10/site-packages/astropy/utils/decorators.py:546, in deprecated_renamed_argument..decorator..wrapper(*args, **kwargs)
544 warnings.warn(msg, warning_type, stacklevel=2)
→ 546 return function(*args, **kwargs)
File /opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-4.0.0/lib/python3.10/site-packages/astropy/io/votable/table.py:160, in parse(source, columns, invalid, verify, chunk_size, table_number, table_id, filename, unit_format, datatype_mapping, _debug_python_based_parser)
156 with iterparser.get_xml_iterator(
157 source,
158 _debug_python_based_parser=_debug_python_based_parser) as iterator:
159 return tree.VOTableFile(
→ 160 config=config, pos=(1, 1)).parse(iterator, config)
File /opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-4.0.0/lib/python3.10/site-packages/astropy/io/votable/tree.py:3601, in VOTableFile.parse(self, iterator, config)
3600 else:
→ 3601 vo_raise(E19, (), config, pos)
3602 config.update(self._get_version_checks())
File /opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-4.0.0/lib/python3.10/site-packages/astropy/io/votable/exceptions.py:112, in vo_raise(exception_class, args, config, pos)
111 config = {}
→ 112 raise exception_class(args, config, pos)
E19: None:1:0: E19: File does not appear to be a VOTABLE
During handling of the above exception, another exception occurred:
DALServiceError Traceback (most recent call last)
Input In [5], in <cell line: 3>()
1 # For more detailed analysis of results, converting
2 # to a pandas dataframe is often very useful (“df” stands for “dataframe”)
----> 3 df = service.search(query, maxrec=max_rec).to_table().to_pandas()
5 # Use an assertion to make sure we got the correct number of results.
6 # assert len(df) == 15670
7 len(df.coord_ra)
File /opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-4.0.0/lib/python3.10/site-packages/pyvo/dal/tap.py:248, in TAPService.run_sync(self, query, language, maxrec, uploads, **keywords)
219 def run_sync(
220 self, query, language=“ADQL”, maxrec=None, uploads=None,
221 **keywords):
222 “”"
223 runs sync query and returns its result
224
(…)
244 TAPResults
245 “”"
246 return self.create_query(
247 query, language=language, maxrec=maxrec, uploads=uploads,
→ 248 **keywords).execute()
File /opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-4.0.0/lib/python3.10/site-packages/pyvo/dal/tap.py:942, in TAPQuery.execute(self)
928 def execute(self):
929 “”"
930 submit the query and return the results as a TAPResults instance
931
(…)
940 for errors parsing the VOTable response
941 “”"
→ 942 return TAPResults(self.execute_votable(), url=self.queryurl, session=self._session)
File /opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-4.0.0/lib/python3.10/site-packages/pyvo/dal/query.py:244, in DALQuery.execute_votable(self, post)
242 return votableparse(self.execute_stream(post=post).read)
243 except Exception as e:
→ 244 self.raise_if_error()
245 raise DALFormatError(e, self.queryurl)
File /opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-4.0.0/lib/python3.10/site-packages/pyvo/dal/query.py:253, in DALQuery.raise_if_error(self)
251 if self._ex:
252 e = self._ex
→ 253 raise DALServiceError.from_except(e, self.queryurl)
DALServiceError: 401 Client Error: Unauthorized for url: https://data.lsst.cloud/api/tap/sync