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

BF: make it [] in case of None being returned #217

Merged
merged 2 commits into from
Aug 9, 2023

Conversation

yarikoptic
Copy link
Member

For some reason few days ago tests started to fail on github actions but not locally. In the logs I see

2023-08-09T02:10:57.8251783Z [ERROR] Failed to execute ['/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py', 'run', '--repo-tag', 'alpine:3.16', '/tmp/pytest-of-runner/pytest-0/test_load_multi_image0/alpine', 'ls']
2023-08-09T02:10:57.8252806Z Traceback (most recent call last):
2023-08-09T02:10:57.8254107Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 243, in <module>
2023-08-09T02:10:57.8254681Z     main(sys.argv)
2023-08-09T02:10:57.8255833Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 238, in main
2023-08-09T02:10:57.8256433Z     namespace.func(namespace)
2023-08-09T02:10:57.8257545Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 164, in cli_run
2023-08-09T02:10:57.8258206Z     image_id = load(namespace.path, namespace.repo_tag, namespace.config)
2023-08-09T02:10:57.8259431Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 135, in load
2023-08-09T02:10:57.8260072Z     image_id = "sha256:" + get_image(path, repo_tag, config)
2023-08-09T02:10:57.8261030Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 98, in get_image
2023-08-09T02:10:57.8261689Z     manifest = [img for img in manifest if repo_tag in img.get("RepoTags", [])]
2023-08-09T02:10:57.8262670Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 98, in <listcomp>
2023-08-09T02:10:57.8263557Z     manifest = [img for img in manifest if repo_tag in img.get("RepoTags", [])]
2023-08-09T02:10:57.8264146Z TypeError: argument of type 'NoneType' is not iterable
2023-08-09T02:10:57.8265305Z Failed to execute ['/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py', 'run', '--repo-tag', 'alpine:3.16', '/tmp/pytest-of-runner/pytest-0/test_load_multi_image0/alpine', 'ls']
2023-08-09T02:10:57.8266015Z Traceback (most recent call last):
2023-08-09T02:10:57.8267005Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 243, in <module>
2023-08-09T02:10:57.8267538Z     main(sys.argv)
2023-08-09T02:10:57.8275594Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 238, in main
2023-08-09T02:10:57.8276373Z     namespace.func(namespace)
2023-08-09T02:10:57.8277519Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 164, in cli_run
2023-08-09T02:10:57.8278199Z     image_id = load(namespace.path, namespace.repo_tag, namespace.config)
2023-08-09T02:10:57.8279059Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 135, in load
2023-08-09T02:10:57.8280204Z     image_id = "sha256:" + get_image(path, repo_tag, config)
2023-08-09T02:10:57.8281300Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 98, in get_image
2023-08-09T02:10:57.8281972Z     manifest = [img for img in manifest if repo_tag in img.get("RepoTags", [])]
2023-08-09T02:10:57.8282831Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 98, in <listcomp>
2023-08-09T02:10:57.8283464Z     manifest = [img for img in manifest if repo_tag in img.get("RepoTags", [])]
2023-08-09T02:10:57.8284095Z TypeError: argument of type 'NoneType' is not iterable

which suggests that img.get("RepoTags", []) returns None, i.e. it is present but None, instead of just being absent and thus defaulting to []. With this change we should "or" into [] then.

Closes (if succeeds testing) #216

For some reason few days ago tests started to fail on github actions but not
locally.  In the logs I see

	2023-08-09T02:10:57.8251783Z [ERROR] Failed to execute ['/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py', 'run', '--repo-tag', 'alpine:3.16', '/tmp/pytest-of-runner/pytest-0/test_load_multi_image0/alpine', 'ls']
	2023-08-09T02:10:57.8252806Z Traceback (most recent call last):
	2023-08-09T02:10:57.8254107Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 243, in <module>
	2023-08-09T02:10:57.8254681Z     main(sys.argv)
	2023-08-09T02:10:57.8255833Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 238, in main
	2023-08-09T02:10:57.8256433Z     namespace.func(namespace)
	2023-08-09T02:10:57.8257545Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 164, in cli_run
	2023-08-09T02:10:57.8258206Z     image_id = load(namespace.path, namespace.repo_tag, namespace.config)
	2023-08-09T02:10:57.8259431Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 135, in load
	2023-08-09T02:10:57.8260072Z     image_id = "sha256:" + get_image(path, repo_tag, config)
	2023-08-09T02:10:57.8261030Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 98, in get_image
	2023-08-09T02:10:57.8261689Z     manifest = [img for img in manifest if repo_tag in img.get("RepoTags", [])]
	2023-08-09T02:10:57.8262670Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 98, in <listcomp>
	2023-08-09T02:10:57.8263557Z     manifest = [img for img in manifest if repo_tag in img.get("RepoTags", [])]
	2023-08-09T02:10:57.8264146Z TypeError: argument of type 'NoneType' is not iterable
	2023-08-09T02:10:57.8265305Z Failed to execute ['/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py', 'run', '--repo-tag', 'alpine:3.16', '/tmp/pytest-of-runner/pytest-0/test_load_multi_image0/alpine', 'ls']
	2023-08-09T02:10:57.8266015Z Traceback (most recent call last):
	2023-08-09T02:10:57.8267005Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 243, in <module>
	2023-08-09T02:10:57.8267538Z     main(sys.argv)
	2023-08-09T02:10:57.8275594Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 238, in main
	2023-08-09T02:10:57.8276373Z     namespace.func(namespace)
	2023-08-09T02:10:57.8277519Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 164, in cli_run
	2023-08-09T02:10:57.8278199Z     image_id = load(namespace.path, namespace.repo_tag, namespace.config)
	2023-08-09T02:10:57.8279059Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 135, in load
	2023-08-09T02:10:57.8280204Z     image_id = "sha256:" + get_image(path, repo_tag, config)
	2023-08-09T02:10:57.8281300Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 98, in get_image
	2023-08-09T02:10:57.8281972Z     manifest = [img for img in manifest if repo_tag in img.get("RepoTags", [])]
	2023-08-09T02:10:57.8282831Z   File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/datalad_container/adapters/docker.py", line 98, in <listcomp>
	2023-08-09T02:10:57.8283464Z     manifest = [img for img in manifest if repo_tag in img.get("RepoTags", [])]
	2023-08-09T02:10:57.8284095Z TypeError: argument of type 'NoneType' is not iterable

which suggests that img.get("RepoTags", []) returns None, i.e. it is present
but None, instead of just being absent and thus defaulting to [].  With this
change we should "or" into [] then.

Closes datalad#216
@yarikoptic yarikoptic added patch Increment the patch version when merged release Create a release when this pr is merged CHANGELOG-missing labels Aug 9, 2023
@codeclimate
Copy link

codeclimate bot commented Aug 9, 2023

Code Climate has analyzed commit c17b255 and detected 0 issues on this pull request.

View more on Code Climate.

@yarikoptic yarikoptic requested a review from jwodder August 9, 2023 18:23
@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (250e897) 93.95% compared to head (c17b255) 93.95%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #217   +/-   ##
=======================================
  Coverage   93.95%   93.95%           
=======================================
  Files          25       25           
  Lines        1091     1091           
=======================================
  Hits         1025     1025           
  Misses         66       66           
Files Changed Coverage Δ
datalad_container/adapters/docker.py 86.60% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yarikoptic yarikoptic merged commit 94f6f76 into datalad:master Aug 9, 2023
@github-actions
Copy link

github-actions bot commented Aug 9, 2023

PR released in 1.2.2

@yarikoptic yarikoptic deleted the bf-repotags branch September 7, 2023 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged release Create a release when this pr is merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants