Skip to content

Commit 9415d71

Browse files
authored
Merge pull request #149 from erik-whiting/add-documentation-pre-GSOC-2022
Add documentation pre-GSOC 2022
2 parents f0fc291 + 05d5a4d commit 9415d71

File tree

5 files changed

+198
-40
lines changed

5 files changed

+198
-40
lines changed

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Help us to make autowrap better and become part of the OpenMS open-source community.
2+
3+
This document is displayed because you either opened an issue or you want to provide your code as a pull request for inclusion into autowrap. Please take a look at the appropriate section below to find some details on how we handle this process.
4+
When interacting with other developers, users or anyone else from our community, please adhere to
5+
[the OpenMS CODE OF CONDUCT](https://github.com/OpenMS/OpenMS/blob/develop/CODE_OF_CONDUCT.md)
6+
7+
# Reporting an Issue:
8+
9+
You most likely came here to:
10+
- report bugs or annoyances
11+
- pose questions
12+
- point out missing documentation
13+
- request new features
14+
15+
If you found a bug, e.g. an autowrap tool crashes during code generation, it is essential to provide some basic information:
16+
- the autowrap version you are running
17+
- the platform you are running autowrap on (Windows 10, ...)
18+
- how you installed autowrap (e.g., from source, pip)
19+
- a description on how to reproduce the bug
20+
- relevant tool output (e.g., error messages)
21+
- data to repoduce the bug (If possible as a GitHub gist. Other platforms like Dropbox, Google Drive links also work. If you can't share the data publicly please indicate this and we will contact you in private.)
22+
23+
If you are an official OpenMS team meber:
24+
- label your issue using github labels (e.g. as: question, defect) that indicate the type of issue and which components of autowrap (blue labels) are affected. The severity is usually assigned by OpenMS maintainers and used internally to e.g. indicate if a bug is a blocker for a new release.
25+
26+
# Opening a Pull Request
27+
28+
Before getting started we recommend taking a look at the OpenMS GitHub-Wiki: https://github.com/OpenMS/OpenMS/wiki#-for-developers
29+
30+
Before you open the pull request, make sure you
31+
- adhere to [our coding conventions](https://github.com/OpenMS/OpenMS/wiki/Coding-conventions)
32+
- have [unit tests and functional tests](https://github.com/OpenMS/OpenMS/wiki/Write-tests)
33+
- Have [proper documentation](https://github.com/OpenMS/OpenMS/wiki/Coding-conventions#doxygen)
34+
35+
A core developer will review your changes to the main development branch (develop) and approve them (or ask for modifications). You may indicate the prefered reviewer(s) by adding links to them in a comment section (e.g., @cbielow @hendrikweisser @hroest @jpfeuffer @timosachsenberg)
36+
37+
Also consider getting in contact with the core developers early. They might provide additional guidance and valuable information on how your specific aim is achieved. This might give you a head start in, for example, developing novel tools or algorithms.
38+
39+
Happy coding!

autowrap/CodeGenerator.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def __init__(self, resolved, instance_mapping, pyx_target_path=None,
149149
self.all_classes = self.classes
150150
self.all_resolved = self.resolved
151151
if len(allDecl) > 0:
152-
152+
153153
self.all_typedefs = []
154154
self.all_enums = []
155155
self.all_functions = []
@@ -191,6 +191,7 @@ def setup_cimport_paths(self):
191191

192192
pxd_dirs = set()
193193
for inst in self.all_classes + self.all_enums + self.all_functions + self.all_typedefs:
194+
# Could this not simply be `for inst in self.all_resolved:` ?
194195
pxd_path = os.path.abspath(inst.cpp_decl.pxd_path)
195196
pxd_dir = os.path.dirname(pxd_path)
196197
pxd_dirs.add(pxd_dir)
@@ -395,7 +396,7 @@ def create_wrapper_for_enum(self, decl, out_codes):
395396

396397
def create_wrapper_for_class(self, r_class, out_codes):
397398
"""Create Cython code for a single class
398-
399+
399400
Note that the cdef class definition and the member variables go into
400401
the .pxd file while the Python-level implementation goes into the .pyx
401402
file. This allows us to cimport these classes later across modules.
@@ -718,7 +719,7 @@ def create_wrapper_for_method(self, cdcl, py_name, methods):
718719
assert len(methods) == 1, "overloaded operator/= not supported"
719720
code = self.create_special_itruediv_method(cdcl, methods[0])
720721
return [code], Code.Code()
721-
722+
722723

723724
if len(methods) == 1:
724725
code, typestubs = self.create_wrapper_for_nonoverloaded_method(cdcl, py_name, methods[0])
@@ -1155,7 +1156,7 @@ def create_special_mul_method(self, cdcl, mdcl):
11551156
| return result
11561157
""", locals())
11571158
return code
1158-
1159+
11591160
def create_special_truediv_method(self, cdcl, mdcl):
11601161
L.info(" create wrapper for operator/")
11611162
assert len(mdcl.arguments) == 1, "operator/ has wrong signature"
@@ -1197,7 +1198,7 @@ def create_special_add_method(self, cdcl, mdcl):
11971198
| return result
11981199
""", locals())
11991200
return code
1200-
1201+
12011202
def create_special_sub_method(self, cdcl, mdcl):
12021203
L.info(" create wrapper for operator-")
12031204
assert len(mdcl.arguments) == 1, "operator- has wrong signature"
@@ -1302,7 +1303,7 @@ def create_special_imul_method(self, cdcl, mdcl):
13021303
self.top_level_code.append(tl)
13031304

13041305
return code
1305-
1306+
13061307
def create_special_itruediv_method(self, cdcl, mdcl):
13071308
L.info(" create wrapper for operator/")
13081309
assert len(mdcl.arguments) == 1, "operator/ has wrong signature"
@@ -1535,7 +1536,7 @@ def create_foreign_cimports(self):
15351536
we may be using in this compilation unit. Since we are passing objects
15361537
as arguments quite frequently, we need to know about all other wrapped
15371538
classes and we need to cimport them.
1538-
1539+
15391540
E.g. if we have module1 containing classA, classB and want to access it
15401541
through the pxd header, then we need to add:
15411542
@@ -1555,7 +1556,7 @@ def create_foreign_cimports(self):
15551556
for resolved in self.allDecl[module]["decls"]:
15561557

15571558
# We need to import classes and enums that could be used in
1558-
# the Cython code in the current module
1559+
# the Cython code in the current module
15591560

15601561
# use Cython name, which correctly imports template classes (instead of C name)
15611562
name = resolved.name
@@ -1578,7 +1579,7 @@ def create_foreign_cimports(self):
15781579
else:
15791580
code.add("from $mname cimport $name", locals())
15801581

1581-
else:
1582+
else:
15821583
L.info("Skip imports from self (own module %s)" % module)
15831584

15841585
self.top_level_code.append(code)

autowrap/DeclResolver.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class is the same as the name of the C++ class.
7979
- wrap-manual-memory: will allow the user to provide manual memory
8080
management of self.inst, therefore the class will
8181
not provide the automated __dealloc__ and inst
82-
attribute (but their presence is still expected).
82+
attribute (but their presence is still expected).
8383
This is useful if you cannot use the shared-ptr
8484
approach to store a reference to the C++ class
8585
(as with singletons for example).
@@ -229,23 +229,24 @@ class ResolvedFunction(ResolvedMethod):
229229

230230
pass
231231

232+
def resolve_decls_from_files(paths, root, num_processes = 1, cython_warn_level = 1):
233+
if num_processes > 1:
234+
return resolve_decls_from_files_multi_thread(paths, root, num_processes, cython_warn_level)
235+
else:
236+
return resolve_decls_from_files_single_thread(paths, root, cython_warn_level)
237+
232238

233-
def resolve_decls_from_files_single_thread(pathes, root, cython_warn_level = 1):
239+
def resolve_decls_from_files_single_thread(paths, root, cython_warn_level = 1):
234240
decls = []
235-
for k, path in enumerate(pathes):
241+
for k, path in enumerate(paths):
236242
full_path = os.path.join(root, path)
237-
if k % 50 == 0:
238-
logger.log(25, "parsing progress %s out of %s" % (k, len(pathes)))
243+
if k % 50 == 0:
244+
logger.log(25, "parsing progress %s out of %s" % (k, len(paths)))
239245
decls.extend(PXDParser.parse_pxd_file(full_path, cython_warn_level))
240246
return _resolve_decls(decls)
241247

242-
def resolve_decls_from_files(pathes, root, num_processes = 1, cython_warn_level = 1):
243-
if num_processes > 1:
244-
return resolve_decls_from_files_multi_thread(pathes, root, num_processes, cython_warn_level)
245-
else:
246-
return resolve_decls_from_files_single_thread(pathes, root, cython_warn_level)
247248

248-
def resolve_decls_from_files_multi_thread(pathes, root, num_processes, cython_warn_level = 1):
249+
def resolve_decls_from_files_multi_thread(paths, root, num_processes, cython_warn_level = 1):
249250
"""Perform parsing with multiple threads
250251
251252
This function distributes the work on `num_processes` processes and each
@@ -257,20 +258,20 @@ def resolve_decls_from_files_multi_thread(pathes, root, num_processes, cython_wa
257258

258259
CONCURRENT_FILES_PER_CORE = 10
259260
pool = mp.Pool(processes=num_processes)
260-
full_pathes = [os.path.join(root, path) for path in pathes]
261+
full_paths = [os.path.join(root, path) for path in paths]
261262

262263
decls = []
263-
while len(full_pathes) > 0:
264-
n_work = len(full_pathes)
264+
while len(full_paths) > 0:
265+
n_work = len(full_paths)
265266
remaining = max(0, n_work - num_processes * CONCURRENT_FILES_PER_CORE)
266-
args = [full_pathes.pop() for k in range(n_work - remaining)]
267-
logger.log(25, "parsing progress %s out of %s with %s processes" % (len(pathes)-remaining, len(pathes), num_processes))
267+
args = [full_paths.pop() for k in range(n_work - remaining)]
268+
logger.log(25, "parsing progress %s out of %s with %s processes" % (len(paths)-remaining, len(paths), num_processes))
268269
parse_pxd_file_warn = partial(PXDParser.parse_pxd_file, warn_level = cython_warn_level)
269270
res = pool.map(parse_pxd_file_warn, args)
270271
for r in res:
271272
decls.extend(r)
272273

273-
return _resolve_decls(decls)
274+
return _resolve_decls(decls)
274275

275276

276277
def resolve_decls_from_string(pxd_in_a_string):
@@ -280,7 +281,7 @@ def resolve_decls_from_string(pxd_in_a_string):
280281
def _resolve_decls(decls):
281282
"""
282283
input:
283-
class_decls ist list of instances of PXDParser.BaseDecl.
284+
class_decls is a list of instances of PXDParser.BaseDecl.
284285
(contains annotations
285286
- about instance names for template parameterized classes
286287
- about inheritance of methods from other classes in class_decls

autowrap/PXDParser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def parse_line_annotations(node, lines):
150150
result[key] += value
151151
except Exception as e:
152152
raise ValueError("Cannot parse '{}'".format(line)) from e
153-
153+
154154
# check for multi line annotations after method declaration
155155
additional_annotations = _parse_multiline_annotations(lines[end:])
156156
# add multi line doc string to result (overwrites single line wrap-doc, if exists)

0 commit comments

Comments
 (0)