You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please ensure your code follows the CGraph coding guidelines. Consistent coding style helps maintain the codebase.
8
+
9
+
Based on Google style guide, with some differences(perhaps):
10
+
11
+
- Function naming: First letter lowercase, camelCase
12
+
```
13
+
int getCode() {
14
+
return 0;
15
+
}
16
+
```
17
+
18
+
- Class and struct naming: First letter uppercase, camelCase
19
+
```
20
+
class MyClass {
21
+
}
22
+
23
+
struct MyStruct {
24
+
}
25
+
```
26
+
27
+
- Variable naming: First letter lowercase, camelCase
28
+
```
29
+
int myVar = 0;
30
+
```
31
+
32
+
- Member variable naming: First letter lowercase, words connected by underscore, ends with underscore
33
+
```
34
+
class MyClass {
35
+
int my_var_;
36
+
}
37
+
38
+
struct MyStruct {
39
+
int my_var_;
40
+
}
41
+
```
42
+
43
+
- Macro naming: All uppercase, words connected by underscore
44
+
```
45
+
#define MY_MACRO (1)
46
+
```
47
+
48
+
- Enum naming: All uppercase, words connected by underscore
49
+
```
50
+
enum MyEnum {
51
+
MY_ENUM_VALUE1,
52
+
MY_ENUM_VALUE2,
53
+
MY_ENUM_VALUE3,
54
+
};
55
+
```
56
+
57
+
### Python
58
+
59
+
Based on the Google Python Style Guide, the basic requirements are as follows:
60
+
61
+
1. Files and Encoding
62
+
-**File Encoding**: Files should be encoded in UTF-8 and usually do not need an encoding declaration at the top of the file (Python 3 uses UTF-8 by default).
63
+
-**File Naming**: First letter uppercase, camelCase, e.g., `MyModule.py`.
64
+
65
+
2. Comments
66
+
-**Module Comments**: Each module should start with a module-level docstring describing the module's purpose, functionality, and main classes or functions. For example:
67
+
```python
68
+
"""
69
+
This module provides utility functions for handling strings.
70
+
71
+
It includes functions for string formatting, splitting, and joining.
72
+
"""
73
+
```
74
+
-**Function and Method Comments**: Functions and methods also require docstrings explaining their purpose, parameters, return values, and possible exceptions. For example:
75
+
```python
76
+
defaddNumbers(a: int, b: int):
77
+
"""
78
+
Add two numbers together.
79
+
80
+
Args:
81
+
a (int): The first number.
82
+
b (int): The second number.
83
+
84
+
Returns:
85
+
int: The sum of a and b.
86
+
"""
87
+
return a + b
88
+
```
89
+
-**Inline Comments**: Use inline comments in the code to explain complexor non-intuitive parts, but don't overuse them. Comments should be concise and clear.
90
+
91
+
3. Classes and Objects
92
+
-**Class Naming**: Class names should use CapWords convention, e.g., `MyClass`.
93
+
-**Class Docstrings**: Classes should include a docstring describing their purpose and main functionality.
94
+
```python
95
+
classMyClass:
96
+
"""
97
+
A simple class that represents a person.
98
+
99
+
Attributes:
100
+
name (str): The name of the person.
101
+
age (int): The age of the person.
102
+
"""
103
+
def__init__(self, name: str, age: int):
104
+
self.name = name
105
+
self.age = age
106
+
107
+
defgetInfo(self):
108
+
"""
109
+
Get the person's information.
110
+
111
+
Returns:
112
+
str: A string containing the person's name and age.
113
+
"""
114
+
returnf"Name: {self.name}, Age: {self.age}"
115
+
```
116
+
-**Member Variable and Method Naming**: Member variables and method names should use lowercase with words separated by underscores, e.g., `my_variable`and`my_method`.
117
+
118
+
4. Functions and Methods
119
+
-**Function Naming**: Function names should use lowercase first letter, camelCase, e.g., `checkResult()`.
120
+
-**Parameter Naming**: Parameter names should also use lowercase first letter, camelCase, and be descriptive, e.g., `myResultValue`.
121
+
-**Function Length**: Functions should be kept short and focused on a single task. Avoid excessively long functions.
122
+
123
+
5. Code Layout
124
+
-**Indentation**: Use 4 spaces for indentation, not tabs.
125
+
-**Line Length**: Limit each line of code to a maximum of 120 characters. If it exceeds, break the line while maintaining code readability. Usually break after operators. For example:
126
+
```python
127
+
result = getResult(arg1, arg2,
128
+
arg3, arg4)
129
+
```
130
+
-**Blank Lines**: Use blank lines to separate logical sections, e.g., two blank lines between functions and classes, one blank line between methods within a class.
131
+
132
+
6. Import Statements
133
+
-**Import Order**: Group import statements in the order of standard library, third-party libraries, and local modules, with a blank line between each group. For example:
134
+
```python
135
+
import os
136
+
import sys
137
+
138
+
import requests
139
+
140
+
from MyModule import MyClass
141
+
```
142
+
-**Avoid Wildcard Imports**: Avoid using wildcard imports like `from module import*`as they can lead to naming conflicts and reduced code readability.
143
+
144
+
7. Exception Handling
145
+
-**Specific Exception Types**: When catching exceptions, specify the exact exception type instead of using a generic `except` statement. For example:
146
+
```python
147
+
try:
148
+
result =1/0
149
+
exceptZeroDivisionError:
150
+
print("Division by zero occurred.")
151
+
```
152
+
153
+
8. Testing
154
+
-**Write Unit Tests**: Write unit tests for your code to ensure correctness and stability. You can use Python's `unittest` or `pytest` testing frameworks.
Copy file name to clipboardExpand all lines: README_en.md
+55-65Lines changed: 55 additions & 65 deletions
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,9 @@
18
18
19
19
## 1. Introduction
20
20
21
-
CGraph, short for <b>C</b>olor <b>Graph</b>, is a cross-platform DAG computing frameworkwithout any third-party dependencies. With the scheduling via `GPipeline`, the purpose of sequential and concurrent executing elements is realized.
21
+
CGraph, short for <b>C</b>olor <b>Graph</b>, is a cross-platform DAG computing framework. It is written by C++11 without any third-party dependencies, Python APIs are also supported.
22
22
23
-
You only need to inherit `GNode` class, implement the `run()` method in the subclass, and set the dependencies as needed to achieve the graphical execution of tasks.
23
+
With the scheduling via `GPipeline`, the purpose of sequential and concurrent executing elements is realized. You only need to inherit `GNode` class, implement the `run()` method in the subclass, and set the dependencies as needed to achieve the graphical execution of tasks.
24
24
25
25
At the same time, you can also control the graph conditional judgment, loop or concurrent execution logic by setting various `GGroup`s, which containing multi-node information by themselves.
26
26
@@ -29,94 +29,84 @@ You can transfer your params in many scenes. It is also possible to extend the f
* This project supports MacOS, Linux, and Windows systems without any third-party dependencies. C++11 is default and lowest version, C++17 is recommended.
34
-
35
-
* For developers using `CLion` as IDE within all platform, open the `CMakeLists.txt` file as project to compile.
36
-
37
-
* Developers on Windows system, using `Visual Studio`(2013 version at least) as IDE, with cmake, enter commands as flowers to build `CGraph.sln` file.
* Compile online, enter [CGraph env online](https://gitpod.io/#/github.com/ChunelFeng/CGraph), log in with your Github id, enter commands as flowers to compile and run your first tutorial.
62
-
```shell
63
-
$ sudo apt-get install cmake -y
64
-
$ ./CGraph-build.sh
65
-
$ ./build/tutorial/T00-HelloCGraph
66
-
```
67
-
68
-
## 3. Demo
69
-
70
-
#### MyNode.h
32
+
## 2. Demo
33
+
34
+
> C++ version
35
+
71
36
```cpp
72
37
#include"CGraph.h"
73
38
74
-
classMyNode1 : publicCGraph::GNode {
39
+
usingnamespaceCGraph;
40
+
41
+
classMyNode1 : publicGNode {
75
42
public:
76
-
CStatus run () override {
77
-
CStatus status;
78
-
printf("[%s], Sleep for 1 second ... \n", this->getName().c_str());
43
+
CStatus run() override {
44
+
printf("[%s], sleep for 1 second ...\n", this->getName().c_str());
79
45
CGRAPH_SLEEP_SECOND(1)
80
-
return status;
46
+
return CStatus();
81
47
}
82
48
};
83
49
84
-
85
-
class MyNode2 : public CGraph::GNode {
50
+
class MyNode2 : public GNode {
86
51
public:
87
-
CStatus run () override {
88
-
CStatus status;
89
-
printf("[%s], Sleep for 1 second ... \n", this->getName().c_str());
52
+
CStatus run() override {
53
+
printf("[%s], sleep for 2 second ...\n", this->getName().c_str());
0 commit comments