auto-optimize 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. auto_optimize/__init__.py +3 -0
  2. auto_optimize/__main__.py +5 -0
  3. auto_optimize/cli.py +651 -0
  4. auto_optimize/skills/auto-optimize-code/LICENSE +21 -0
  5. auto_optimize/skills/auto-optimize-code/SKILL.md +251 -0
  6. auto_optimize/skills/auto-optimize-code/VERSION +1 -0
  7. auto_optimize/skills/auto-optimize-code/references/algorithm.md +182 -0
  8. auto_optimize/skills/auto-optimize-code/references/changes.md +146 -0
  9. auto_optimize/skills/auto-optimize-code/references/cli.md +206 -0
  10. auto_optimize/skills/auto-optimize-code/references/dashboard.md +203 -0
  11. auto_optimize/skills/auto-optimize-code/references/documents.md +55 -0
  12. auto_optimize/skills/auto-optimize-code/references/extending.md +87 -0
  13. auto_optimize/skills/auto-optimize-code/references/external-validation.md +98 -0
  14. auto_optimize/skills/auto-optimize-code/references/glossary.md +134 -0
  15. auto_optimize/skills/auto-optimize-code/references/idea-miner.md +108 -0
  16. auto_optimize/skills/auto-optimize-code/references/issue-bugs.md +182 -0
  17. auto_optimize/skills/auto-optimize-code/references/layout.md +300 -0
  18. auto_optimize/skills/auto-optimize-code/references/main-session.md +45 -0
  19. auto_optimize/skills/auto-optimize-code/references/measuring.md +208 -0
  20. auto_optimize/skills/auto-optimize-code/references/pr-optimization.md +127 -0
  21. auto_optimize/skills/auto-optimize-code/references/pr-tests.md +254 -0
  22. auto_optimize/skills/auto-optimize-code/references/promotion.md +133 -0
  23. auto_optimize/skills/auto-optimize-code/references/reading-a-search.md +65 -0
  24. auto_optimize/skills/auto-optimize-code/references/repo-mode.md +224 -0
  25. auto_optimize/skills/auto-optimize-code/references/resume.md +81 -0
  26. auto_optimize/skills/auto-optimize-code/references/shared-knowledge.md +114 -0
  27. auto_optimize/skills/auto-optimize-code/references/step0-interview.md +298 -0
  28. auto_optimize/skills/auto-optimize-code/references/step1-unit-tests.md +136 -0
  29. auto_optimize/skills/auto-optimize-code/references/step2-baseline.md +708 -0
  30. auto_optimize/skills/auto-optimize-code/references/step3-rounds.md +350 -0
  31. auto_optimize/skills/auto-optimize-code/references/step4-final.md +121 -0
  32. auto_optimize/skills/auto-optimize-code/references/step5-ship.md +220 -0
  33. auto_optimize/skills/auto-optimize-code/references/step6-finish.md +67 -0
  34. auto_optimize/skills/auto-optimize-code/references/subagent.md +467 -0
  35. auto_optimize/skills/auto-optimize-code/references/symptoms.md +67 -0
  36. auto_optimize/skills/auto-optimize-code/references/writing-briefs.md +117 -0
  37. auto_optimize/skills/auto-optimize-code/scripts/attribution.py +156 -0
  38. auto_optimize/skills/auto-optimize-code/scripts/autoopt.py +12863 -0
  39. auto_optimize/skills/auto-optimize-code/scripts/check_seeding.py +334 -0
  40. auto_optimize/skills/auto-optimize-code/scripts/cold.py +90 -0
  41. auto_optimize/skills/auto-optimize-code/scripts/dashboard/README.md +165 -0
  42. auto_optimize/skills/auto-optimize-code/scripts/dashboard/autoopt_monitor.py +850 -0
  43. auto_optimize/skills/auto-optimize-code/scripts/dashboard/gpu_scan.py +954 -0
  44. auto_optimize/skills/auto-optimize-code/scripts/dashboard/monitor_writer.py +684 -0
  45. auto_optimize/skills/auto-optimize-code/scripts/dashboard/scan.py +1030 -0
  46. auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/dashboard.css +775 -0
  47. auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/dashboard.js +3652 -0
  48. auto_optimize/skills/auto-optimize-code/scripts/dashboard/static/index.html +191 -0
  49. auto_optimize/skills/auto-optimize-code/scripts/issue_body.py +2118 -0
  50. auto_optimize/skills/auto-optimize-code/scripts/lint_text.py +448 -0
  51. auto_optimize/skills/auto-optimize-code/scripts/opt_pr_body.py +894 -0
  52. auto_optimize/skills/auto-optimize-code/scripts/opt_pr_tables.py +367 -0
  53. auto_optimize/skills/auto-optimize-code/scripts/paired.py +188 -0
  54. auto_optimize/skills/auto-optimize-code/scripts/preflight.py +280 -0
  55. auto_optimize/skills/auto-optimize-code/scripts/probe_run.py +72 -0
  56. auto_optimize/skills/auto-optimize-code/scripts/publish.py +385 -0
  57. auto_optimize/skills/auto-optimize-code/scripts/run_iteration.py +1382 -0
  58. auto_optimize/skills/auto-optimize-code/scripts/ship.py +1193 -0
  59. auto_optimize/skills/auto-optimize-code/scripts/stages.py +651 -0
  60. auto_optimize/skills/auto-optimize-code/scripts/tests_pr_body.py +1267 -0
  61. auto_optimize/skills/auto-optimize-code/scripts/tests_pr_push.py +426 -0
  62. auto_optimize/skills/auto-optimize-code/scripts/tests_pr_tables.py +779 -0
  63. auto_optimize-1.0.0.dist-info/METADATA +610 -0
  64. auto_optimize-1.0.0.dist-info/RECORD +67 -0
  65. auto_optimize-1.0.0.dist-info/WHEEL +4 -0
  66. auto_optimize-1.0.0.dist-info/entry_points.txt +2 -0
  67. auto_optimize-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,156 @@
1
+ """The fixed parts of the documents step 5 posts: the title rule, the
2
+ stand-in numbers, and the bug report's fixed sentences. Nothing is added
3
+ that names the tool or says how a document was written.
4
+
5
+ The optimization PR, the unit-test PR and the bug report are rendered by
6
+ `opt_pr_body.py`, `tests_pr_body.py` and `issue_body.py`, and opened by
7
+ `autoopt.py pr`, `tests_pr_push.py` and `issue_body.py file`. Each takes these
8
+ parts from here, so the wording is the same every time and a document that
9
+ breaks a rule is refused before it leaves the machine.
10
+
11
+ python3 attribution.py check --kind optimization|tests|issue --title T --body FILE
12
+ """
13
+
14
+ TITLE_LIMIT = 72
15
+
16
+ KINDS = ('optimization', 'tests', 'issue')
17
+
18
+ # How likely a user is to meet a bug and what it costs them, most severe
19
+ # first. The bug report's table divides the bugs by it, and its first
20
+ # paragraph says what the levels mean.
21
+ SEVERITIES = (
22
+ ('high', 'likely to be met in ordinary use, with wrong output or a crash'),
23
+ ('medium', 'needs unusual input, options or an environment, or costs time '
24
+ 'rather than correctness'),
25
+ ('low', 'an edge case, malformed input, a rarely used option, or a '
26
+ 'documentation mismatch'),
27
+ )
28
+ SEVERITY_KEY = ('Severity is our estimate of how likely a user is to meet the '
29
+ 'bug and what it costs them: {}.'.format('; '.join('**{}**, {}'.format(key,
30
+ meaning) for key, meaning in SEVERITIES)))
31
+
32
+ # Fixed sentences that end a bug report's first paragraph: many of the bugs
33
+ # are edge cases, and what the severity levels mean.
34
+ ISSUE_NOTES = (
35
+ 'Many of the bugs below are likely edge cases that a user may never '
36
+ 'experience in practice, and the table after this paragraph divides them '
37
+ 'by severity.',
38
+ SEVERITY_KEY)
39
+
40
+ # Stand-ins a draft carries for a number that does not exist yet: the bug
41
+ # report's and the unit-test PR's. `ship.py post` fills each once that
42
+ # document is posted; a document that still holds one is not ready to open.
43
+ PLACEHOLDERS = ('#<bug issue>', '#<tests PR>')
44
+
45
+ # Where an optimization PR's first paragraph points, and the section it
46
+ # points to.
47
+ CHECKED_HEADING = '## How the output was checked'
48
+ CHECKED_LINK = '(#how-the-output-was-checked)'
49
+
50
+
51
+ def plural(count):
52
+ return '' if count == 1 else 's'
53
+
54
+
55
+ def placeholder_problems(text):
56
+ """One problem for each stand-in `text` still holds."""
57
+
58
+ return ['it still holds {}, the number of a document not posted yet; '
59
+ '`ship.py post` fills it'.format(held) for held in PLACEHOLDERS
60
+ if held in text]
61
+
62
+
63
+ def title_problems(text):
64
+ """What is wrong with a title, as a list: it starts with a capital letter,
65
+ does not end with a period, and fits in TITLE_LIMIT characters."""
66
+
67
+ text = text.strip()
68
+ problems = []
69
+
70
+ if not text:
71
+ problems.append('it is empty')
72
+ elif not text[0].isupper():
73
+ problems.append('it must start with a capital letter ("Vectorize '
74
+ 'column scoring", "Bugs in the clustering script")')
75
+
76
+ if text.endswith('.'):
77
+ problems.append('it must not end with a period')
78
+
79
+ if len(text) > TITLE_LIMIT:
80
+ problems.append('it is {} characters; the limit is {}'.format(len(text),
81
+ TITLE_LIMIT))
82
+
83
+ return problems
84
+
85
+
86
+ def first_paragraph(text):
87
+ """The first paragraph of `text`, its lines joined by spaces."""
88
+
89
+ return ' '.join(text.strip().split('\n\n')[0].split())
90
+
91
+
92
+ def opening_problems(kind, text):
93
+ """What is wrong with how a `kind` document begins, as a list: a bug
94
+ report's first paragraph ends with ISSUE_NOTES, and an optimization PR's
95
+ links its *How the output was checked* section, which exists."""
96
+
97
+ problems = []
98
+ paragraph = first_paragraph(text)
99
+
100
+ if not paragraph:
101
+ return ['the body is empty']
102
+
103
+ if kind == 'issue':
104
+ missing = [note for note in ISSUE_NOTES if note not in paragraph]
105
+
106
+ if missing:
107
+ problems.append('the first paragraph must hold the fixed '
108
+ 'sentence(s): "{}"'.format('" "'.join(missing)))
109
+
110
+ if kind == 'optimization':
111
+ if CHECKED_LINK not in paragraph:
112
+ problems.append('the first paragraph must link {}'.format(
113
+ CHECKED_LINK.strip('()')))
114
+
115
+ if CHECKED_HEADING not in text.splitlines():
116
+ problems.append('the body has no "{}" section'.format(
117
+ CHECKED_HEADING))
118
+
119
+ return problems
120
+
121
+
122
+ def problems(kind, title, text):
123
+ """Every problem with a `kind` document's title and body."""
124
+
125
+ return (['title: ' + p for p in title_problems(title)] + ['body: ' + p
126
+ for p in opening_problems(kind, text) + placeholder_problems(text)])
127
+
128
+
129
+ def main(argv=None):
130
+ import argparse
131
+ import sys
132
+
133
+ parser = argparse.ArgumentParser(description='Check a document step 5 '
134
+ 'posts: exits 1 and lists every problem with its title or body.')
135
+ sub = parser.add_subparsers(dest='command', required=True)
136
+ check = sub.add_parser('check', help='check a title and a body file')
137
+ check.add_argument('--kind', required=True, choices=KINDS)
138
+ check.add_argument('--title', required=True)
139
+ check.add_argument('--body', required=True, help='the body file')
140
+ args = parser.parse_args(argv)
141
+
142
+ with open(args.body, encoding='utf-8') as infile:
143
+ text = infile.read()
144
+
145
+ found = problems(args.kind, args.title, text)
146
+
147
+ if found:
148
+ sys.stderr.write('refused:\n' + ''.join(' ' + p + '\n' for p in found))
149
+ return 1
150
+
151
+ print('ok: {}'.format(args.title.strip()))
152
+ return 0
153
+
154
+
155
+ if __name__ == '__main__':
156
+ raise SystemExit(main())