14
14
https://github.com/pytorch/vision/pull/1321#issuecomment-531033978
15
15
"""
16
16
17
+ import os .path
18
+
17
19
import jinja2
18
- from jinja2 import select_autoescape
19
20
import yaml
20
- import os . path
21
+ from jinja2 import select_autoescape
21
22
22
23
23
24
PYTHON_VERSIONS = ["3.7" , "3.8" , "3.9" ]
24
25
25
- DOC_VERSION = (' linux' , ' 3.8' )
26
+ DOC_VERSION = (" linux" , " 3.8" )
26
27
27
28
28
- def build_workflows (prefix = '' , upload = False , filter_branch = None , indentation = 6 ):
29
+ def build_workflows (prefix = "" , upload = False , filter_branch = None , indentation = 6 ):
29
30
w = []
30
31
for btype in ["wheel" , "conda" ]:
31
32
for os_type in ["linux" , "macos" , "windows" ]:
32
33
for python_version in PYTHON_VERSIONS :
33
34
fb = filter_branch
34
- if not fb and (os_type == 'linux' and
35
- btype == 'wheel' and
36
- python_version == '3.8' ):
35
+ if not fb and (os_type == "linux" and btype == "wheel" and python_version == "3.8" ):
37
36
# the fields must match the build_docs "requires" dependency
38
- fb = ' /.*/'
37
+ fb = " /.*/"
39
38
w += build_workflow_pair (btype , os_type , python_version , fb , prefix , upload )
40
39
41
40
if not filter_branch :
42
41
# Build on every pull request, but upload only on nightly and tags
43
- w += build_doc_job ('/.*/' )
44
- w += upload_doc_job ('nightly' )
45
- w += docstring_parameters_sync_job (None )
42
+ w += build_doc_job ("/.*/" )
43
+ w += upload_doc_job ("nightly" )
46
44
47
45
return indent (indentation , w )
48
46
49
47
50
- def build_workflow_pair (btype , os_type , python_version , filter_branch , prefix = '' , upload = False ):
48
+ def build_workflow_pair (btype , os_type , python_version , filter_branch , prefix = "" , upload = False ):
51
49
w = []
52
50
base_workflow_name = f"{ prefix } binary_{ os_type } _{ btype } _py{ python_version } "
53
51
w .append (generate_base_workflow (base_workflow_name , python_version , filter_branch , os_type , btype ))
54
52
55
53
if upload :
56
54
w .append (generate_upload_workflow (base_workflow_name , filter_branch , btype ))
57
- if filter_branch == ' nightly' and os_type in [' linux' , ' windows' ]:
58
- pydistro = ' pip' if btype == ' wheel' else ' conda'
55
+ if filter_branch == " nightly" and os_type in [" linux" , " windows" ]:
56
+ pydistro = " pip" if btype == " wheel" else " conda"
59
57
w .append (generate_smoketest_workflow (pydistro , base_workflow_name , filter_branch , python_version , os_type ))
60
58
return w
61
59
@@ -64,7 +62,9 @@ def build_doc_job(filter_branch):
64
62
job = {
65
63
"name" : "build_docs" ,
66
64
"python_version" : "3.8" ,
67
- "requires" : ["binary_linux_wheel_py3.8" , ],
65
+ "requires" : [
66
+ "binary_linux_wheel_py3.8" ,
67
+ ],
68
68
}
69
69
70
70
if filter_branch :
@@ -77,26 +77,16 @@ def upload_doc_job(filter_branch):
77
77
"name" : "upload_docs" ,
78
78
"context" : "org-member" ,
79
79
"python_version" : "3.8" ,
80
- "requires" : ["build_docs" , ],
80
+ "requires" : [
81
+ "build_docs" ,
82
+ ],
81
83
}
82
84
83
85
if filter_branch :
84
86
job ["filters" ] = gen_filter_branch_tree (filter_branch )
85
87
return [{"upload_docs" : job }]
86
88
87
89
88
- def docstring_parameters_sync_job (filter_branch ):
89
- job = {
90
- "name" : "docstring_parameters_sync" ,
91
- "python_version" : "3.8" ,
92
- "requires" : ["binary_linux_wheel_py3.8" , ],
93
- }
94
-
95
- if filter_branch :
96
- job ["filters" ] = gen_filter_branch_tree (filter_branch )
97
- return [{"docstring_parameters_sync" : job }]
98
-
99
-
100
90
def generate_base_workflow (base_workflow_name , python_version , filter_branch , os_type , btype ):
101
91
d = {
102
92
"name" : base_workflow_name ,
@@ -111,14 +101,12 @@ def generate_base_workflow(base_workflow_name, python_version, filter_branch, os
111
101
112
102
def gen_filter_branch_tree (branch_name ):
113
103
return {
114
- "branches" : {
115
- "only" : branch_name
116
- },
104
+ "branches" : {"only" : branch_name },
117
105
"tags" : {
118
106
# Using a raw string here to avoid having to escape
119
107
# anything
120
108
"only" : r"/v[0-9]+(\.[0-9]+)*-rc[0-9]+/"
121
- }
109
+ },
122
110
}
123
111
124
112
@@ -160,21 +148,16 @@ def indent(indentation, data_list):
160
148
def unittest_workflows (indentation = 6 ):
161
149
w = []
162
150
for os_type in ["linux" , "windows" ]:
163
- for i , python_version in enumerate (PYTHON_VERSIONS ):
164
- w .append ({
165
- f"unittest_{ os_type } " : {
166
- "name" : f"unittest_{ os_type } _py{ python_version } " ,
167
- "python_version" : python_version ,
168
- }
169
- })
170
-
171
- if i == 0 and os_type == "linux" :
172
- w .append ({
173
- "stylecheck" : {
174
- "name" : f"stylecheck_py{ python_version } " ,
151
+ for python_version in PYTHON_VERSIONS :
152
+ w .append (
153
+ {
154
+ f"unittest_{ os_type } " : {
155
+ "name" : f"unittest_{ os_type } _py{ python_version } " ,
175
156
"python_version" : python_version ,
176
157
}
177
- })
158
+ }
159
+ )
160
+
178
161
return indent (indentation , w )
179
162
180
163
@@ -183,12 +166,14 @@ def unittest_workflows(indentation=6):
183
166
env = jinja2 .Environment (
184
167
loader = jinja2 .FileSystemLoader (d ),
185
168
lstrip_blocks = True ,
186
- autoescape = select_autoescape (enabled_extensions = (' html' , ' xml' )),
169
+ autoescape = select_autoescape (enabled_extensions = (" html" , " xml" )),
187
170
)
188
171
189
- with open (os .path .join (d , 'config.yml' ), 'w' ) as f :
190
- f .write (env .get_template ('config.yml.in' ).render (
191
- build_workflows = build_workflows ,
192
- unittest_workflows = unittest_workflows ,
193
- ))
172
+ with open (os .path .join (d , "config.yml" ), "w" ) as f :
173
+ f .write (
174
+ env .get_template ("config.yml.in" ).render (
175
+ build_workflows = build_workflows ,
176
+ unittest_workflows = unittest_workflows ,
177
+ )
178
+ )
194
179
f .write ("\n " )
0 commit comments