Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added RunTime set of images that are slimmer and a jupyter bonus #68

Open
wants to merge 133 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
155bf1b
Added RunTime set of images that are slimmer and available in jupyter
aloysbaillet Aug 12, 2020
3229093
Added xpra ^Cd Xorg abilities - still WIP
aloysbaillet Aug 19, 2020
ed1b190
Added dockerstats command
aloysbaillet Aug 19, 2020
99bd05e
Fix incorrect "Jira" url.
KelSolaar Sep 23, 2020
e626d61
Build clang-tools-extra for clang-tidy
Simran-B Sep 11, 2020
597e66f
Add tests
Simran-B Sep 21, 2020
68fb061
Enforce LF line endings for .sh files
Simran-B Sep 11, 2020
05a5483
ShellCheck
Simran-B Sep 27, 2020
ffa439c
Whitespace
Simran-B Sep 20, 2020
70736e6
Fuse an ENV into another
Simran-B Sep 20, 2020
657f81b
Remove useless echo
Simran-B Sep 21, 2020
ed8a8ad
Revert accidental removal of export
Simran-B Sep 23, 2020
36de366
Suppress non-zero exit code of Sonar build-wrapper again
Simran-B Sep 24, 2020
957e2a8
The build-wrapper doesn't have a --help or --version option
Simran-B Sep 25, 2020
cc63adf
Fix yum devtoolset install error
aloysbaillet Sep 28, 2020
4ad7fe4
Added new clang variants for ci-common, ci-osl and ci-openvdb
aloysbaillet Sep 28, 2020
ed9533c
Fixing build
aloysbaillet Sep 29, 2020
2928fe4
Lock pre-commit black to same version as pipenv
aloysbaillet Sep 29, 2020
c79e16f
Fixed ci-common tags
aloysbaillet Sep 29, 2020
81db3ac
Revert black semi-upgrade by locking it down
aloysbaillet Sep 30, 2020
2a6c343
Updated versions and changelog
aloysbaillet Sep 30, 2020
2296869
Fixed test
aloysbaillet Oct 8, 2020
d2862e2
Updated clang7 from clang-7.0.1 to clang-7.1.0
aloysbaillet Oct 13, 2020
0a75f13
Updated tests
aloysbaillet Oct 13, 2020
858cef5
Added missing version info for 2018-clang7 and 2020-clang7
aloysbaillet Oct 17, 2020
b1688b2
Added clang variants to vfxall
aloysbaillet Oct 17, 2020
2c57641
Updated changelog
aloysbaillet Oct 17, 2020
075a336
Updated OpenVDB and USD to latest
aloysbaillet Oct 17, 2020
e82cc26
Updated changelog
aloysbaillet Oct 17, 2020
c6db97a
Fixed 'most most' typo
aloysbaillet Oct 17, 2020
a8f084d
Fixed location of
aloysbaillet Oct 17, 2020
75e226c
Adding more clang combos and clang-11
aloysbaillet Oct 20, 2020
de5bffb
Fixed missing clang version for vfxall
aloysbaillet Oct 20, 2020
98cc838
--amend
aloysbaillet Oct 20, 2020
f47589c
Added changelog
aloysbaillet Oct 21, 2020
7a8c4d8
Added CUDA_VERSION build argument
aloysbaillet Aug 29, 2020
ea642e5
Updated gl-dependent docker image versions with cuda-11
aloysbaillet Aug 29, 2020
bab0df9
Exposing package versions to docker images
aloysbaillet Oct 31, 2020
31d88a2
Package cleanup with licenses, new ninja and sonar
aloysbaillet Nov 1, 2020
1964d4f
Updated all licenses and some versions
aloysbaillet Nov 1, 2020
489d1a0
Fixed boost and oiio
aloysbaillet Nov 1, 2020
8b6a105
Fixed ocio build
aloysbaillet Nov 1, 2020
0871d83
Incremented packages and images versions
aloysbaillet Nov 1, 2020
b0d066e
Fixed tests
aloysbaillet Nov 2, 2020
856ed97
Big python version cleanup
aloysbaillet Nov 2, 2020
8bcc7b1
Further cleanup
aloysbaillet Nov 2, 2020
3407dee
Further cleanup
aloysbaillet Nov 2, 2020
bcb92f4
Added 2 more cleanup
aloysbaillet Nov 2, 2020
19bf2d2
Fixed typo
aloysbaillet Nov 2, 2020
ce583bf
Fixed vfxall
aloysbaillet Nov 3, 2020
f4f1de2
Fixed ci-otio
aloysbaillet Nov 3, 2020
8ea788f
CI Images now all templated, with bonus Readme!
aloysbaillet Nov 4, 2020
6e55bef
Added extra_commands and begin changelog
aloysbaillet Nov 4, 2020
490cc92
Added dockergen --check option
aloysbaillet Nov 5, 2020
a170524
Updated changelog and enabled cuda-11 for osd
aloysbaillet Nov 5, 2020
8535b9d
Added docker hub description upload
aloysbaillet Nov 5, 2020
f1a950e
Run dockergen --check during tests
aloysbaillet Nov 5, 2020
5b94848
Synced setup.py from pipenv
aloysbaillet Nov 5, 2020
895a7a9
Added a doc line on dockergen
aloysbaillet Nov 5, 2020
ddf5dda
Addressed feedback on yaml files, also templating ci-common
aloysbaillet Nov 6, 2020
2231958
Added dockergen tests
aloysbaillet Nov 6, 2020
b89b76f
Do not push package overview yet
aloysbaillet Nov 6, 2020
1eac3d4
Fixed dockergen test
aloysbaillet Nov 6, 2020
0d679d4
Updated image.yaml references
aloysbaillet Nov 6, 2020
96258a7
Renamed template file extensions to .jinja2
aloysbaillet Nov 7, 2020
806fc09
Proper resource handling for files so aswfdocker can be used in wheels
aloysbaillet Nov 7, 2020
d85a3da
Fixed setup.py for pypi use
aloysbaillet Nov 7, 2020
f810833
Switched to importlib_resources to support earlier python versions
aloysbaillet Nov 7, 2020
e4debc8
New patch version
aloysbaillet Nov 7, 2020
142ae1d
New patch and added missing packages
aloysbaillet Nov 7, 2020
88da49f
Updated pipfile.lock
aloysbaillet Nov 7, 2020
f3856a8
Removed bad pyproject.toml
aloysbaillet Nov 7, 2020
8d66a54
Split package dockerfile alongside groups to speed builds
aloysbaillet Nov 8, 2020
f60aebc
Fixed missing openexr for usd
aloysbaillet Nov 8, 2020
87b6436
New aswfdocker patch version
aloysbaillet Nov 8, 2020
c9bfea2
Fixed qt package build
aloysbaillet Nov 9, 2020
f1503b5
Improved docker image readme
aloysbaillet Nov 9, 2020
aed0e4a
Truncate description to the allowed maximum of 100 chars
aloysbaillet Nov 10, 2020
ebe7a37
Re-ordered some builds and groups to make release easier
aloysbaillet Nov 10, 2020
9fcbbeb
Mentioned sonarqube update
aloysbaillet Nov 10, 2020
9d62589
Added big re-release example script
aloysbaillet Nov 10, 2020
5c15e77
Fixed test failure after group change
aloysbaillet Nov 10, 2020
80ea29c
Added ASWF_ prefix in front of all env vars
aloysbaillet Nov 11, 2020
c58de25
Now deletes pre-existing release and tags if present
aloysbaillet Nov 12, 2020
f5b2f2a
New aswfdocker version
aloysbaillet Nov 12, 2020
7c71fa6
Reverted blosc version change for VFX2021
aloysbaillet Nov 12, 2020
b7bad03
Fixed missing packages in ci-osl
aloysbaillet Nov 12, 2020
4e6ce20
Spelling: Docker Hub, organization
Simran-B Dec 2, 2020
bdab9e2
Properly link to Contribution Sign-Off
Simran-B Dec 2, 2020
aa2c958
Formatting
Simran-B Dec 2, 2020
bf5f0aa
Add #wg-ci Slack channel to list
Simran-B Dec 2, 2020
805f64e
Capitalization, spelling
Simran-B Dec 3, 2020
03753a3
Improve template formatting
Simran-B Dec 3, 2020
d97a4e1
Update status
Simran-B Dec 3, 2020
22cb680
Avoid 'here' link labels
Simran-B Dec 3, 2020
4faf71e
Formatting for CHANGELOG
Simran-B Dec 3, 2020
fc0fbd4
More capitalization fixes
Simran-B Dec 3, 2020
cbf9bd9
Update generated Dockerfiles and Readmes
Simran-B Dec 3, 2020
7e7ac85
A previous commit added an ASWF_ prefix where it didn't belong.
glevner Jan 14, 2021
c59145c
Working 2021 Qt 5.15
aloysbaillet Dec 20, 2020
f1cfa20
With backward compatibility with older Qt versions
aloysbaillet Dec 20, 2020
ffe7fc4
Added changelogs and updated all Qt-dependent version numbers
aloysbaillet Dec 21, 2020
36bca8a
Removed duplicated yum packages - single rpm/line
aloysbaillet Dec 21, 2020
062155f
Apply suggestions from code review
aloysbaillet Dec 21, 2020
8c21c31
Update a few more package versions to 2021
aloysbaillet Jan 14, 2021
4d44cf8
Updated versions of non-vfx platform packages to be current for 2021
aloysbaillet Jan 17, 2021
d3ce203
Updated changelog
aloysbaillet Jan 17, 2021
4d1570a
Updated 2021 versions
aloysbaillet Jan 18, 2021
47c53e7
Updated USD version
aloysbaillet Jan 21, 2021
f3e649d
New versions for oiio and ocio
aloysbaillet Jan 21, 2021
de8dc65
Added pybind11 and fixed oiio/ocio builds
aloysbaillet Jan 29, 2021
5ff5d2c
Fixed get-pip url for python-2
aloysbaillet Jan 29, 2021
2e45d71
Fixed tests and dockergen
aloysbaillet Jan 29, 2021
1a8abab
Fixed OSL build by adding pybind11 package and running build_pujixml
aloysbaillet Jan 30, 2021
9c3dcc5
Tweak shell scripts to install packages elsewhere.
glevner Jan 15, 2021
e228632
Added an explanatory comment as suggested.
glevner Jan 15, 2021
467784e
Added missing info in changelog
aloysbaillet Feb 2, 2021
e29cc35
New aswfdocker python package version
aloysbaillet Feb 2, 2021
b98650e
Fixed failure to free space on newer ubuntu
aloysbaillet Feb 2, 2021
4bceb88
Added atomicwrites on windows only as needed by pytest
aloysbaillet Feb 3, 2021
ea75f05
Moved versions.yaml into data folder as Windows does not like symlinks
aloysbaillet Feb 7, 2021
4d75037
Added debug messages for Index
aloysbaillet Feb 7, 2021
85f2e8f
Make tests pass on Windows
aloysbaillet Feb 7, 2021
b4e16f2
Nicer test fix from @Simran-B
aloysbaillet Feb 7, 2021
3b09e95
Fixed test_util
aloysbaillet Feb 7, 2021
ea597ec
Reformat
aloysbaillet Feb 7, 2021
0b99090
Fixed wrong path test
aloysbaillet Feb 8, 2021
103d810
Switch to open method to fix zipp.Path usage
aloysbaillet Feb 9, 2021
cfad835
Added prospector profile to include linting of tests
aloysbaillet Feb 13, 2021
411259d
Added RunTime set of images that are slimmer and available in jupyter
aloysbaillet Aug 12, 2020
063938f
Added dockerstats command
aloysbaillet Aug 19, 2020
868f2e6
Rebasing properly
aloysbaillet Feb 13, 2021
174a5f1
Remerged master before commit cleanup
aloysbaillet Feb 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/docker-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
group: [img-common-1] # Extra groups come from the include next
include:
- group: img-common-1
type: IMAGE
type: CI_IMAGE
name: common
version: 1
test: common
- group: img-common-2
type: IMAGE
type: CI_IMAGE
name: common
version: 2
test: common
Expand All @@ -46,31 +46,31 @@ jobs:
version: 2021
test: ""
- group: img-base-2021
type: IMAGE
type: CI_IMAGE
name: base
common_version: 2
version: 2021
test: base
- group: img-vfx1-2021
type: IMAGE
type: CI_IMAGE
name: vfx1
common_version: 2
version: 2021
test: openvdb
- group: img-vfx2-2021
type: IMAGE
type: CI_IMAGE
name: vfx2
common_version: 2
version: 2021
test: ""
- group: img-usd-2021
type: IMAGE
type: CI_IMAGE
name: usd
common_version: 2
version: 2021
test: ""
- group: img-vfxall-2021
type: IMAGE
type: CI_IMAGE
name: vfxall
common_version: 2
version: 2021
Expand Down Expand Up @@ -116,11 +116,11 @@ jobs:
--source-branch $GITHUB_REF \
--verbose \
build \
--ci-image-type IMAGE \
--ci-image-type CI_IMAGE \
--group common \
--version ${{ matrix.common_version }}
name: Optionally build local ci-common Docker Image for downstream images
if: ${{ matrix.name != 'common' && matrix.type == 'IMAGE' }}
if: ${{ matrix.name != 'common' && matrix.type == 'CI_IMAGE' }}

- run: |
set -ex
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Example use: just build a single package for testing:
# Build and push USD package to aswftesting
aswfdocker --verbose build -t PACKAGE --group vfx --version 2019 --target usd --push
# Build and push ci-vfxall image to aswftesting
aswfdocker --verbose build -t IMAGE --group vfx --version 2019 --target vfxall --push
aswfdocker --verbose build -t CI_IMAGE --group vfx --version 2019 --target vfxall --push
```

### Migrate
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ but it is recommended to speed up large builds.

To build all images (very unlikely to succeed unless run on a very very powerful machine!):
```bash
aswfdocker --verbose build -t IMAGE
aswfdocker --verbose build -t CI_IMAGE
```

To build a single image:
```bash
# First list the available CI images to know which package belong to which "group":
aswfdocker images
# Then run the build
aswfdocker --verbose build -t IMAGE --group vfx1 --version 2019 --target openexr
aswfdocker --verbose build -t CI_IMAGE --group vfx1 --version 2019 --target openexr
# Or the simpler but less flexible syntax:
aswfdocker build -n aswftesting/ci-openexr:2019
```
40 changes: 32 additions & 8 deletions python/aswfdocker/cli/aswfdocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,39 @@ def packages():

@cli.command()
def images():
"""Lists all known ci images in this format: IMAGEGROUP/ci-IMAGE:VERSION
"""Lists all known ci images in this format: IMAGEGROUP/IMAGE:VERSION
"""
for group, images in constants.GROUPS[constants.ImageType.IMAGE].items():
for image in images:
image_name = utils.get_image_name(constants.ImageType.IMAGE, image)
for version in index.Index().iter_versions(
constants.ImageType.IMAGE, image
):
click.echo(f"{group}/{image_name}:{version}")
for image_type in (constants.ImageType.CI_IMAGE, constants.ImageType.RT_IMAGE):
for group, images in constants.GROUPS[image_type].items():
for image in images:
image_name = utils.get_image_name(image_type, image)
for version in index.Index().iter_versions(image_type, image):
click.echo(f"{group}/{image_name}:{version}")


@click.option(
"--sizes", "-s", is_flag=True, help="Display Sizes",
)
@cli.command()
def dockerstats(sizes):
"""Lists all known ci images in this format: IMAGEGROUP/IMAGE:VERSION
"""
if sizes:
total_size = 0
for org, image_type, image in utils.iter_all_images():
image_name = utils.get_image_name(image_type, image)
for tag, size in utils.get_image_sizes(org, image_name).items():
click.echo(f"{org}/{image_name}:{tag} size={size}")
total_size += size
click.echo(f"Total size={total_size}")
else:
total_pull = 0
for org, image_type, image in utils.iter_all_images():
image_name = utils.get_image_name(image_type, image)
pull_count = utils.get_image_pull_count(org, image_name)
click.echo(f"{org}/{image_name} pull_count={pull_count}")
total_pull += pull_count
click.echo(f"Total pull_count={total_pull}")


@cli.command()
Expand Down
12 changes: 9 additions & 3 deletions python/aswfdocker/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@


class ImageType(enum.Enum):
IMAGE = "image"
CI_IMAGE = "ci-image"
RT_IMAGE = "rt-image"
PACKAGE = "package"


Expand All @@ -24,14 +25,19 @@ class ImageType(enum.Enum):
"vfx2": ["opensubdiv", "ptex", "openvdb", "usd", "otio"],
"vfx3": ["partio", "osl"],
},
ImageType.IMAGE: {
ImageType.CI_IMAGE: {
"common": ["common"],
"base": ["base"],
"vfx1": ["openexr", "openvdb", "opencue"],
"vfx2": ["ocio", "osl", "otio"],
"usd": ["usd"],
"vfxall": ["vfxall"],
},
ImageType.RT_IMAGE: {
"base": ["base"],
"vfx1": ["vfxall"],
"vfx2": ["vfxall-jupyter"],
},
}

VERSION_INFO = {
Expand Down Expand Up @@ -95,4 +101,4 @@ class ImageType(enum.Enum):
f"https://github.com/{MAIN_GITHUB_ASWF_ORG}/{MAIN_GITHUB_REPO_NAME}"
)

IMAGE_NAME_REGEX = r"(refs/tags/)?(?P<org>[a-z]+)/ci-(?P<package>package\-)?(?P<image>[a-z0-9]+)[:/](?P<version>[0-9\.]+)"
IMAGE_NAME_REGEX = r"(refs/tags/)?(?P<org>[a-z]+)/(?P<ci>ci-)?(?P<rt>rt-)?(?P<package>package\-)?(?P<image>[a-z0-9\-]+)[:/](?P<version>[0-9\.]+)"
4 changes: 3 additions & 1 deletion python/aswfdocker/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def __init__(self):
def _get_key(self, image_type: constants.ImageType):
if image_type == constants.ImageType.PACKAGE:
return "ci-packages"
return "ci-images"
if image_type == constants.ImageType.CI_IMAGE:
return "ci-images"
return "rt-images"

def iter_images(self, image_type: constants.ImageType):
"""
Expand Down
10 changes: 5 additions & 5 deletions python/aswfdocker/tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ def test_image_base_2019_dict(self):
groupinfo.GroupInfo(
names=["base"],
versions=["2019"],
type_=constants.ImageType.IMAGE,
type_=constants.ImageType.CI_IMAGE,
targets=[],
),
)
base_version = list(
index.Index().iter_versions(constants.ImageType.IMAGE, "base")
index.Index().iter_versions(constants.ImageType.CI_IMAGE, "base")
)[1]
self.assertEqual(
b.make_bake_dict(),
Expand Down Expand Up @@ -118,12 +118,12 @@ def test_image_base_2019_2020_dict(self):
groupinfo.GroupInfo(
names=["base"],
versions=["2019", "2020"],
type_=constants.ImageType.IMAGE,
type_=constants.ImageType.CI_IMAGE,
targets=[],
),
)
base_versions = list(
index.Index().iter_versions(constants.ImageType.IMAGE, "base")
index.Index().iter_versions(constants.ImageType.CI_IMAGE, "base")
)
self.assertEqual(
b.make_bake_dict(),
Expand Down Expand Up @@ -220,7 +220,7 @@ def test_builder_cli_fromtag(self):
self.assertFalse(result.exception)
self.assertEqual(
result.output,
f"INFO:aswfdocker.builder:Would build: 'docker buildx bake -f {tempfile.gettempdir()}/docker-bake-IMAGE-common-1.json --progress auto'\n",
f"INFO:aswfdocker.builder:Would build: 'docker buildx bake -f {tempfile.gettempdir()}/docker-bake-CI_IMAGE-common-1.json --progress auto'\n",
)
self.assertEqual(result.exit_code, 0)

Expand Down
13 changes: 9 additions & 4 deletions python/aswfdocker/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ def test_iter_images(self):
self.assertEqual(packages[0], "clang")

def test_get_versions(self):
images = list(self.index.iter_images(constants.ImageType.IMAGE))
self.assertGreater(len(images), 1)
self.assertEqual(images[0], "common")
versions = list(self.index.iter_versions(constants.ImageType.IMAGE, images[0]))
ciimages = list(self.index.iter_images(constants.ImageType.CI_IMAGE))
self.assertGreater(len(ciimages), 1)
self.assertEqual(ciimages[0], "common")
rtimages = list(self.index.iter_images(constants.ImageType.RT_IMAGE))
self.assertGreater(len(rtimages), 1)
self.assertEqual(rtimages[0], "base")
versions = list(
self.index.iter_versions(constants.ImageType.CI_IMAGE, ciimages[0])
)
self.assertGreaterEqual(len(versions), 1)
self.assertTrue(versions[0].startswith("1."))
8 changes: 6 additions & 2 deletions python/aswfdocker/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ def test_image_def_from_name(self):
utils.get_image_spec("aswf/ci-package-openexr_2018")
self.assertEqual(
utils.get_image_spec("aswftesting/ci-common:1"),
("aswftesting", constants.ImageType.IMAGE, "common", "1"),
("aswftesting", constants.ImageType.CI_IMAGE, "common", "1"),
)
self.assertEqual(
utils.get_image_spec("aswftesting/rt-base:2019"),
("aswftesting", constants.ImageType.RT_IMAGE, "base", "2019"),
)
self.assertEqual(
utils.get_image_spec("aswf/ci-package-openexr:2018"),
Expand Down Expand Up @@ -164,7 +168,7 @@ def test_cli_images(self):
imgs = result.output.split("\n")
self.assertGreater(len(imgs), 15)
common_version = list(
index.Index().iter_versions(constants.ImageType.IMAGE, "common")
index.Index().iter_versions(constants.ImageType.CI_IMAGE, "common")
)[0]
self.assertEqual(
imgs[0], f"common/ci-common:{common_version}",
Expand Down
54 changes: 52 additions & 2 deletions python/aswfdocker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import subprocess
import datetime
import logging
import json
import urllib.request

from aswfdocker import constants

Expand Down Expand Up @@ -82,7 +84,9 @@ def download_package(repo_root: str, docker_org: str, package: str, version: str
def get_image_name(image_type: constants.ImageType, image: str):
if image_type == constants.ImageType.PACKAGE:
return f"ci-package-{image}"
return f"ci-{image}"
if image_type == constants.ImageType.CI_IMAGE:
return f"ci-{image}"
return f"rt-{image}"


IMAGE_NAME_REGEXC = re.compile(constants.IMAGE_NAME_REGEX)
Expand All @@ -97,8 +101,14 @@ def get_image_spec(name: str):
org = m.group("org")
if m.group("package"):
image_type = constants.ImageType.PACKAGE
elif m.group("ci"):
image_type = constants.ImageType.CI_IMAGE
elif m.group("rt"):
image_type = constants.ImageType.RT_IMAGE
else:
image_type = constants.ImageType.IMAGE
raise RuntimeError(
f"Image name does not conform to expected format (missing image type): {constants.IMAGE_NAME_REGEX}"
)
image = m.group("image")
version = m.group("version")
logger.debug("get_image_spec found %s: %s/%s:%s", image_type, org, image, version)
Expand All @@ -111,3 +121,43 @@ def get_group_from_image(image_type: constants.ImageType, image: str):
if img == image:
return group
raise RuntimeError(f"Cannot find group for image {image}")


def get_image_pull_count(docker_org, image):
url = f"https://hub.docker.com/v2/repositories/{docker_org}/{image}"
try:
d = json.loads(urllib.request.urlopen(url).read())
return d["pull_count"]
except urllib.error.HTTPError:
logger.debug("Failed to load data from URL %r", url)
return 0


def get_image_sizes(docker_org, image):
sizes = {}
url = f"https://hub.docker.com/v2/repositories/{docker_org}/{image}/tags/"
try:
d = json.loads(urllib.request.urlopen(url).read())
except urllib.error.HTTPError:
logger.debug("Failed to load data from URL %r", url)
return sizes
digests = set()
for tag in d["results"]:
digest = tag["images"][0]["digest"]
if digest in digests:
continue
digests.add(digest)
sizes[tag["name"]] = tag["full_size"]
return sizes


def iter_all_images():
for org in (constants.TESTING_DOCKER_ORG, constants.PUBLISH_DOCKER_ORG):
for image_type in (
constants.ImageType.PACKAGE,
constants.ImageType.CI_IMAGE,
constants.ImageType.RT_IMAGE,
):
for _, images in constants.GROUPS[image_type].items():
for image in images:
yield org, image_type, image
Loading