File tree Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Original file line number Diff line number Diff line change
1
+ .. _custom_pipelines :
2
+
3
+ Custom Pipelines
4
+ ================
5
+
6
+ A pipeline always inherits from the ``Pipeline `` base class :ref: `pipeline_base_class `
7
+ It define steps using the ``steps `` class method.
8
+
9
+ Pipeline registration
10
+ ---------------------
11
+
12
+ Built-in pipelines are located in scanpipe/pipelines/ and registered during the
13
+ ScanCode.io installation.
14
+
15
+ Custom pipelines can be added as python files in the TBD/ directory and will be
16
+ automatically registered at runtime.
17
+
18
+ Create a Pipeline
19
+ -----------------
20
+
21
+ Create a new Python file ``my_pipeline.py `` in the TBD/ directory.
22
+
23
+ .. code-block :: python
24
+
25
+ from scanpipe.pipelines import Pipeline
26
+
27
+ class MyPipeline (Pipeline ):
28
+
29
+ @ classmethod
30
+ def steps (cls ):
31
+ return (
32
+ cls .step1,
33
+ cls .step2,
34
+ )
35
+
36
+ def step1 (self ):
37
+ pass
38
+
39
+ def step2 (self ):
40
+ pass
41
+
42
+
43
+ .. tip ::
44
+ Have a look in the scanpipe/pipelines/ directory for more pipeline examples.
45
+
46
+ Modify existing Pipelines
47
+ -------------------------
48
+
49
+ Any existing pipeline can be reused as a base and customized.
50
+ You may want to override existing steps, add new ones, and remove some.
51
+
52
+ .. code-block :: python
53
+
54
+ from scanpipe.pipelines.scan_codebase import ScanCodebase
55
+
56
+ class MyCustomScan (ScanCodebase ):
57
+
58
+ @ classmethod
59
+ def steps (cls ):
60
+ return (
61
+ # Original steps from the ScanCodebase pipeline
62
+ cls .copy_inputs_to_codebase_directory,
63
+ cls .run_extractcode,
64
+ cls .run_scancode,
65
+ cls .build_inventory_from_scan,
66
+
67
+ # Commented-out as I'm not interested in a csv output
68
+ # cls.csv_output,
69
+
70
+ # My extra steps
71
+ cls .extra_step1,
72
+ cls .extra_step2,
73
+ )
74
+
75
+ def extra_step1 (self ):
76
+ pass
77
+
78
+ def extra_step2 (self ):
79
+ pass
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ you’ll find information on:
32
32
33
33
scanpipe-concepts
34
34
scanpipe-pipelines
35
+ custom-pipelines
35
36
scanpipe-pipes
36
37
scanpipe-output
37
38
scanpipe-command-line
Original file line number Diff line number Diff line change 3
3
Pipelines
4
4
=========
5
5
6
+ .. _pipeline_base_class :
7
+
6
8
Pipeline Base Class
7
9
-------------------
8
10
.. autoclass :: scanpipe.pipelines.Pipeline()
You can’t perform that action at this time.
0 commit comments