Merge ~bdrung/autopkgtest-cloud/+git/autopkgtest-package-configs:sort into ~ubuntu-release/autopkgtest-cloud/+git/autopkgtest-package-configs:main

Proposed by Benjamin Drung
Status: Rejected
Rejected by: Skia
Proposed branch: ~bdrung/autopkgtest-cloud/+git/autopkgtest-package-configs:sort
Merge into: ~ubuntu-release/autopkgtest-cloud/+git/autopkgtest-package-configs:main
Diff against target: 185 lines (+76/-24)
3 files modified
README.md (+4/-0)
big_packages (+24/-24)
sort (+48/-0)
Reviewer Review Type Date Requested Status
Skia Disapprove
Steve Langasek Disapprove
Review via email: mp+427519@code.launchpad.net

Description of the change

I don't like keeping an sorted list sorted when adding new entries. Therefore add a sort script to sort big_packages and long_tests and sort those two files.

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) wrote :

Uses python3 natsort module which is not part of the python3 package and I see no declaration of this added dependency anywhere useful.

Seems rather complicated for something that could be done just as well for our purposes with the 'sort' command in the coreutils package. (I don't think the use of natsort really matters here, the point is that they *be* sorted for ease of maintenance, not that they use any particular collation order.)

review: Disapprove
Revision history for this message
Benjamin Drung (bdrung) wrote :

I tried with the sort command, but there is no option for naturally sorting. Would a Python script acceptable that does not need the natsort module?

Revision history for this message
Steve Langasek (vorlon) wrote :

On Mon, Aug 01, 2022 at 07:39:22AM -0000, Benjamin Drung wrote:

> I tried with the sort command, but there is no option for naturally
> sorting. Would a Python script acceptable that does not need the natsort
> module?

Why do you consider natural sorting important here? As I said I don't think
the sort method is important.

Revision history for this message
Benjamin Drung (bdrung) wrote :

1. The files are currently kindish sorted naturally.

2. I prefer to have openjdk-8 sorted before openjdk-13 and python3.10 after python3.9. This is less confusing when adding new version or dropping old ones.

3. "./sort" is shorter than "LANG=C sort big_packages | sponge big_packages" (okay, that could be put in a short shell script).

Revision history for this message
Skia (hyask) wrote :

This currently doesn't work due to comments in `big_packages` (yes, they are supported [1]).
Steve's comments about the `python3-natsort` dependency still stands.

I'll add:
- ideally, introducing any kind `sort` script should come with enforcing it in the CI
- any decent text editor has a `sort` function too

[1]: https://git.launchpad.net/autopkgtest-cloud/tree/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker#n275

review: Disapprove

Unmerged commits

142b3ad... by Benjamin Drung

Add sort script

Add sort script to sort big_packages and long_tests.

Signed-off-by: Benjamin Drung <email address hidden>

79e293b... by Benjamin Drung

Sort big_packages and long_tests

Signed-off-by: Benjamin Drung <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/README.md b/README.md
2index 7b38276..4d46aaf 100644
3--- a/README.md
4+++ b/README.md
5@@ -20,11 +20,15 @@ Entries here run on the `package_size_big` Openstack flavour as opposed to the
6 which run on Openstack (not `lxd`). Entries here also get a longer
7 `--timeout-test`.
8
9+The entries in `big_packages` are kept sorted with the `sort` script.
10+
11 ## long_tests
12
13 Entries here get a longer timeout, currently defined in the code of
14 `autopkgtest-cloud`.
15
16+The entries in `long_tests` are kept sorted with the `sort` script.
17+
18 ## never_run
19
20 Entries here are never run. A worker which encounters one of these will
21diff --git a/big_packages b/big_packages
22index 6e1e32c..a2dc162 100644
23--- a/big_packages
24+++ b/big_packages
25@@ -11,9 +11,9 @@ androguard/armhf
26 androguard/i386
27 androguard/ppc64el
28 androguard/s390x
29+asmjit/arm64
30 assimp/amd64
31 assimp/i386
32-asmjit/arm64
33 asymptote/amd64
34 asymptote/arm64
35 asymptote/ppc64el
36@@ -66,9 +66,9 @@ cl-ironclad/amd64
37 cl-ironclad/arm64
38 cl-ironclad/i386
39 cod-tools/ppc64el
40+cross-toolchain-base/ppc64el
41 cross-toolchain-base-mipsen/amd64
42 cross-toolchain-base-mipsen/i386
43-cross-toolchain-base/ppc64el
44 cwltool/arm64
45 cwltool/ppc64el
46 dask/amd64
47@@ -171,18 +171,18 @@ link-grammar/arm64
48 link-grammar/ppc64el
49 link-grammar/s390x
50 lintian/arm64
51-linux-*/amd64
52-linux-*/arm64
53-linux-*/armhf
54-linux-*/i386
55-linux-*/ppc64el
56-linux-*/s390x
57 linux/amd64
58 linux/arm64
59 linux/armhf
60 linux/i386
61 linux/ppc64el
62 linux/s390x
63+linux-*/amd64
64+linux-*/arm64
65+linux-*/armhf
66+linux-*/i386
67+linux-*/ppc64el
68+linux-*/s390x
69 lttng-modules/amd64
70 lttng-modules/arm64
71 lttng-modules/armhf
72@@ -245,6 +245,12 @@ octave-parallel/i386
73 octave-parallel/ppc64el
74 octave-parallel/s390x
75 onetbb/arm64
76+openjdk-8/amd64
77+openjdk-8/arm64
78+openjdk-8/armhf
79+openjdk-8/i386
80+openjdk-8/ppc64el
81+openjdk-8/s390x
82 openjdk-13/amd64
83 openjdk-13/i386
84 openjdk-13/ppc64el
85@@ -253,12 +259,6 @@ openjdk-14/amd64
86 openjdk-14/i386
87 openjdk-14/ppc64el
88 openjdk-14/s390x
89-openjdk-8/amd64
90-openjdk-8/arm64
91-openjdk-8/armhf
92-openjdk-8/i386
93-openjdk-8/ppc64el
94-openjdk-8/s390x
95 openjdk-lts/amd64
96 openjdk-lts/arm64
97 openjdk-lts/armhf
98@@ -292,6 +292,16 @@ pyresample/ppc64el
99 pyresample/s390x
100 pyside2/amd64
101 pyside2/arm64
102+python2.7/amd64
103+python2.7/i386
104+python3.6/amd64
105+python3.6/i386
106+python3.7/amd64
107+python3.7/i386
108+python3.8/amd64
109+python3.8/i386
110+python3.9/ppc64el
111+python3.10/ppc64el
112 python-cffi/amd64
113 python-cffi/arm64
114 python-cffi/armhf
115@@ -326,16 +336,6 @@ python-ruffus/ppc64el
116 python-ruffus/s390x
117 python-scipy/amd64
118 python-scipy/i386
119-python2.7/amd64
120-python2.7/i386
121-python3.6/amd64
122-python3.6/i386
123-python3.7/amd64
124-python3.7/i386
125-python3.8/amd64
126-python3.8/i386
127-python3.9/ppc64el
128-python3.10/ppc64el
129 q2-feature-classifier/amd64
130 q2-feature-classifier/arm64
131 q2-feature-classifier/i386
132diff --git a/sort b/sort
133new file mode 100755
134index 0000000..f494852
135--- /dev/null
136+++ b/sort
137@@ -0,0 +1,48 @@
138+#!/usr/bin/python3
139+
140+"""Sort files naturally."""
141+
142+import argparse
143+import logging
144+import os
145+import sys
146+
147+import natsort
148+
149+LOG_FORMAT = "%(name)s %(levelname)s: %(message)s"
150+
151+
152+def sort(filename: str, encoding: str = "utf-8"):
153+ """Sort given file naturally."""
154+ logger = logging.getLogger(os.path.basename(sys.argv[0]))
155+ with open(filename, encoding=encoding) as textfile:
156+ content = textfile.read()
157+ sorted_content = "".join(
158+ "/".join(x)
159+ for x in natsort.natsorted(
160+ [x.split("/") for x in content.splitlines(keepends=True)]
161+ )
162+ )
163+ if sorted_content == content:
164+ logger.info("`%s' is already sorted.", filename)
165+ return
166+ logger.info("Writing sorted `%s'...", filename)
167+ with open(filename, "w", encoding=encoding) as textfile:
168+ textfile.write(sorted_content)
169+
170+
171+def main():
172+ """Sort files naturally."""
173+ parser = argparse.ArgumentParser()
174+ parser.add_argument(
175+ "file", nargs="*", default=["big_packages", "long_tests"]
176+ )
177+ args = parser.parse_args()
178+ logging.basicConfig(format=LOG_FORMAT, level=logging.INFO)
179+
180+ for filename in args.file:
181+ sort(filename)
182+
183+
184+if __name__ == "__main__":
185+ main()

Subscribers

People subscribed via source and target branches