pcdshub / pcds-envs

conda environments used by PCDS
Other
1 stars 9 forks source link

Investigate speedups for update_tags.py #338

Closed ZLLentz closed 2 months ago

ZLLentz commented 2 months ago

Inspired by #336

update_tags.py is very slow and routinely gunks up the CI builds

conda search = 30s+ per package mamba repoquery = 5s per package anaconda show = 3s per package

looking into using the binstar api directly

ZLLentz commented 2 months ago

Using binstar, which gives me all the packages and their versions all at once in one api call:

In [1]: from binstar_client import Binstar

In [2]: binstar = Binstar()

In [3]: binstar.user_packages("pcds-tag")
Out[3]:
[{'name': 'ads_async',
  'id': '64309e44452061e687be6bca',
  'package_types': ['conda'],
  'summary': 'Python TwinCAT ADS async tools',
  'description': '',
  'home': 'https://github.com/pcdshub/ads-async',
  'public': True,
  'owner': 'pcds-tag',
  'full_name': 'pcds-tag/ads_async',
  'url': 'http://api.anaconda.org/packages/pcds-tag/ads_async',
  'html_url': 'http://anaconda.org/pcds-tag/ads_async',
  'versions': ['0.3.1'],
  'latest_version': '0.3.1',
  'platforms': {'noarch': '0.3.1'},
  'conda_platforms': ['noarch'],
  'revision': 2,
  'license': 'SLAC Open License',
  'license_url': None,
  'dev_url': None,
  'doc_url': None,
  'source_git_url': None,
  'source_git_tag': None,
  'app_entry': {},
  'app_type': {},
  'app_summary': {},
  'builds': ['py_0']},
<snip>
In [5]: %time pcds_tag_pkgs = binstar.user_packages("pcds-tag")
CPU times: user 5.16 ms, sys: 783 µs, total: 5.95 ms
Wall time: 828 ms

In [6]: %time conda_forge_pkgs = binstar.user_packages("conda-forge")
---------------------------------------------------------------------------
ServerError                               Traceback (most recent call last)
File <timed exec>:1, in <module>

File /cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.4/lib/python3.9/site-packages/binstar_client/__init__.py:291, in Binstar.user_packages(self, login, platform, package_type, type_, access)
    288     arguments['access'] = access
    290 res = self.session.get(url, params=arguments)
--> 291 self._check_response(res)
    293 return res.json()

File /cds/group/pcds/pyps/conda/py39/envs/pcds-5.8.4/lib/python3.9/site-packages/binstar_client/__init__.py:229, in Binstar._check_response(self, res, allowed)
    226 elif res.status_code >= 500:
    227     ErrCls = errors.ServerError
--> 229 raise ErrCls(msg, res.status_code)

ServerError: ('?: Undefined error ([GET] https://api.anaconda.org/packages/conda-forge -> 524)', 524)
ZLLentz commented 2 months ago
In [7]: %time binstar.package("conda-forge", "pcdsdevices")
CPU times: user 9.64 ms, sys: 41 µs, total: 9.68 ms
Wall time: 437 ms
Out[7]:
{'name': 'pcdsdevices',
 'id': '5e7c6bb6fe6b2a01a1c7c67a',
 'package_types': ['conda'],
 'summary': 'Collection of Ophyd device subclasses for IOCs unique to the Linac Coherent Light Source (LCLS) at SLAC',
 'description': '',
 'home': 'https://github.com/pcdshub/pcdsdevices',
 'public': True,
 'owner': {'company': '',
  'location': '',
  'login': 'conda-forge',
  'name': 'conda-forge',
  'url': '',
  'description': 'A community-led collection of recipes, build infrastructure, and distributions for the conda package manager.',
  'created_at': '2015-04-11 10:15:08.727000+00:00',
  'user_type': 'org'},
 'full_name': 'conda-forge/pcdsdevices',
 'url': 'http://api.anaconda.org/packages/conda-forge/pcdsdevices',
 'html_url': 'http://anaconda.org/conda-forge/pcdsdevices',
 'versions': ['2.4.0',
  '2.5.0',
  '2.6.0',
  '2.7.0',
  '2.8.0',
  '2.9.0',
  '2.10.0',
  '2.11.0',
  '3.0.0',
  '3.1.0',
  '3.2.0',
  '3.3.0',
  '4.0.0',
  '4.1.0',
  '4.2.0',
  '4.3.0',
  '4.3.1',
  '4.3.2',
  '4.4.0',
  '4.5.0',
  '4.6.0',
  '4.6.1',
  '4.7.0',
  '4.7.1',
  '4.8.0',
  '4.9.0',
  '5.0.0',
  '5.0.1',
  '5.0.2',
  '5.1.0',
  '5.2.0',
  '6.0.0',
  '6.1.0',
  '6.2.0',
  '6.3.0',
  '7.0.0',
  '7.0.1',
  '7.1.0',
  '7.2.0',
  '7.3.0',
  '7.4.0',
  '7.4.1',
  '7.4.2',
  '7.4.3',
  '8.0.0',
  '8.1.0',
  '8.2.0',
  '8.3.0',
  '8.4.0'],
 'latest_version': '8.4.0',
<snip>