Skip to content

Commit

Permalink
Merge pull request #340 from ZLLentz/enh_update_tags_speed
Browse files Browse the repository at this point in the history
ENH: speed up update_tags.py from 30m -> 30s and re-apply results
  • Loading branch information
ZLLentz authored Aug 20, 2024
2 parents 549f971 + f623d0f commit 1a04871
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 42 deletions.
42 changes: 21 additions & 21 deletions envs/pcds/conda-packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ anaconda-client>=1.12.3
apischema>=0.18.0
archapp>=1.1.0
atef>=1.4.0
atlassian-python-api>=3.41.11
black>=24.4.0
atlassian-python-api>=3.41.14
black>=24.8.0
blark>=0.8.1
bluesky-live>=0.0.8
bluesky-queueserver>=0.0.18
Expand All @@ -14,23 +14,23 @@ bokeh>=1.0.1
botorch>=0.4.0
caproto>=1.1.1
coloredlogs>=15.0.1
conda-pack>=0.7.1
conda-smithy>=3.34.1
conda-pack>=0.8.0
conda-smithy>=3.38.0
cookiecutter>=2.1.1
cython>=0.29.34
datashader>=0.14.4
elog>=1.2.3
epicsmacrolib>=0.6.1
flake8>=7.0.0
flake8>=7.1.1
flask>=3.0.3
fzf>=0.50.0
gdb>=14.2
gh>=2.48.0
fzf>=0.54.3
gdb>=15.1
gh>=2.54.0
gpytorch>=1.4.2
grpcio-tools>=1.51.1
h5py>=3.3.0
happi>=2.5.0
hklpy>=1.1.0
hklpy>=1.1.1
holoviews>=1.10.9
hutch-python>=1.20.0
hxrsnd>=0.3.1
Expand All @@ -41,12 +41,12 @@ lightpath>=1.0.4
line_profiler>=4.1.1
lucid>=0.10.3
lxml>=4.8.0
memray>=1.12.0
memray>=1.13.4
mysqlclient>=2.0.3
nabs>=1.5.4
numpy>=1.14
opencv>=4.5.1
openssl>=3.2.1
openssl>=3.3.1
pandas>=1.5.3
panel>=0.14.4
papermill>=2.3.4
Expand All @@ -58,29 +58,29 @@ pcdsdevices>=8.4.0
pcdsutils>=0.14.1
pcdswidgets>=0.8.3
periodictable>=1.5.2
pipdeptree>=2.18.1
pmgr>=2.1.2
pipdeptree>=2.23.1
pmgr>=2.1.3
pmpsdb_client>=1.2.0
pre-commit>=3.7.0
pre-commit>=3.8.0
psdaq-control-minimal>=3.3.38
psdm_qs_cli>=0.3.7
pswalker>=1.0.8
pyaudio>=0.2.13
pyca>=3.2.0
pyca>=3.2.1
pycln>=2.4.0
pydm>=1.22.1
pyepics>=3.5.2
pydm>=1.24.1
pyepics>=3.5.6
pyfiglet>=0.8
pymongo>=4.3.3
py-spy>=0.3.14
pytables>=3.6.1
pytest>=8.1.1
pytest>=8.3.2
pytest-qt>=4.4.0
pytest-repeat>=0.9.2
pytest-xdist>=3.5.0
pytest-xdist>=3.6.1
pytmc>=2.16.0
pytorch>=2.0.0
pyupgrade>=3.15.2
pyupgrade>=3.17.0
pyyaml>=6.0
qdarkstyle>=3.1
qrcode>=7.4.2
Expand All @@ -100,7 +100,7 @@ suitcase-mongo>=0.3.1
suitcase-msgpack>=0.3.0
suitcase-specfile>=0.2.5
suitcase-tiff>=0.4.0
timechart>=1.5.1
timechart>=1.5.3
toml>=0.10.2
transfocate>=0.5.8
typhos>=3.1.1
Expand Down
45 changes: 24 additions & 21 deletions scripts/update_tags.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
import argparse
import json
import re
import subprocess
from pathlib import Path

import requests
from binstar_client import Binstar
from binstar_client.errors import BinstarError
from packaging import version

CHANNELS = ['conda-forge', 'pcds-tag', 'lcls-ii']
client = None


def get_client() -> Binstar:
global client
if client is None:
client = Binstar()
return client


def latest_version(package):
info = subprocess.check_output(['conda', 'search', '--json', package],
universal_newlines=True)
info_list = json.loads(info)[package]
channel_versions = {}
client = get_client()
versions_list = None
for ch in CHANNELS:
try:
info = client.package(ch, package)
except BinstarError:
continue
else:
# latest_version key is not necessarily correct, we need to check ourselves
versions_list = info["versions"]
break
if versions_list is None:
raise RuntimeError(f"{package} not found in any channel: {CHANNELS}")
latest_version = "0.0.0"
for info_item in info_list:
item_version = info_item['version']
item_channel = info_item['channel']
for ch in CHANNELS:
if ch in item_channel:
item_channel = ch
break
for item_version in versions_list:
try:
if version.parse(item_version) > version.parse(latest_version):
latest_version = item_version
latest_ch_ver = channel_versions.setdefault(item_channel, "0.0.0")
if version.parse(item_version) > version.parse(latest_ch_ver):
channel_versions[item_channel] = item_version
except version.InvalidVersion:
# Some packages can have malformed version numbers
# Just ignore these and move on
pass
if channel_versions.get('conda-forge', latest_version) != latest_version:
print(
f'Warning! {package}={latest_version} '
'is not ready on conda-forge! '
'Building with this config is likely to fail!'
)
return latest_version


Expand Down

0 comments on commit 1a04871

Please sign in to comment.