Skip to content

Commit 1918d1b

Browse files
contribs
1 parent 356c36f commit 1918d1b

File tree

4 files changed

+368
-23
lines changed

4 files changed

+368
-23
lines changed

CODE_OF_CONDUCT.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, caste, color, religion, or sexual
10+
identity and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the overall
26+
community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or advances of
31+
any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email address,
35+
without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official email address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
[INSERT CONTACT METHOD].
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series of
86+
actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or permanent
93+
ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within the
113+
community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.1, available at
119+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120+
121+
Community Impact Guidelines were inspired by
122+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123+
124+
For answers to common questions about this code of conduct, see the FAQ at
125+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126+
[https://www.contributor-covenant.org/translations][translations].
127+
128+
[homepage]: https://www.contributor-covenant.org
129+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130+
[Mozilla CoC]: https://github.com/mozilla/diversity
131+
[FAQ]: https://www.contributor-covenant.org/faq
132+
[translations]: https://www.contributor-covenant.org/translations
133+

CONTRIBUTING.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Contribution Guidelines
2+
3+
## Issues
4+
If you discover an issue with an algorithm, or test, open an issue to point out areas for improvement.
5+
If you are comfortable with it, implement the fix and open a PR.
6+
7+
8+
## Adding tests
9+
See the [testing contributors guide](tests/CONTRIBUTING.md)
10+
11+
## Coding Standards
12+
13+
### Languages
14+
15+
*GSQL*
16+
- Follow the [GSQL Style Guide](https://docs.tigergraph.com/gsql-ref/current/appendix/gsql-style-guide)
17+
18+
*Python*
19+
- Use the [ruff formatter](https://docs.astral.sh/ruff/formatter/#the-ruff-formatter) to format your code
20+
- tests: pytest and networkx wherever applicable
21+
22+
*C/CPP*
23+
24+
25+
## Pull Requests
26+
- Make sure git knows your name and email address:
27+
```
28+
$ git config user.name "J. Random User"
29+
$ git config user.email "[email protected]"
30+
```
31+
- The name and email address must be valid as we cannot accept anonymous contributions.
32+
- Write good commit messages.
33+
- Concise commit messages that describe your changes help us better understand your contributions.
34+
35+
## General Guidelines
36+
37+
Ensure your pull request (PR) adheres to the following guidelines:
38+
39+
- Try to make the name concise and descriptive.
40+
- Give a good description of the change being made. Since this is very subjective, see the [Updating Your Pull Request (PR)](#updating-your-pull-request-pr) section below for further details.
41+
- Every pull request should be associated with one or more issues. If no issue exists yet, please create your own.
42+
- Make sure that all applicable issues are mentioned somewhere in the PR description. This can be done by typing # to bring up a list of issues.
43+
44+
### Updating Your Pull Request (PR)
45+
46+
A lot of times, making a PR adhere to the standards above can be difficult. If the maintainers notice anything that we'd like changed, we'll ask you to edit your PR before we merge it.
47+
This applies to both the content documented in the PR and the changed contained within the branch being merged. There's no need to open a new PR. Just edit the existing one.
48+
49+
---
50+
51+
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
52+
53+
[email]: mailto:[email protected]

tests/CONTRIBUTING.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Contribution Guidelines for Adding Tests
2+
3+
### Contents
4+
5+
- [Running the tests](#running-the-tests)
6+
- [Directory Layout](#directory-layout)
7+
- [Adding tests](#adding-tests)
8+
- [Available Graphs](#available-graphs)
9+
10+
## Running the tests
11+
12+
Execute the following to download the dependencies and run the tests. Make sure you're in a venv.
13+
14+
```sh
15+
echo '
16+
HOST_NAME="https://tg-hostname"
17+
USER_NAME=tigergraph
18+
PASS=tigergraph
19+
' >> test/.env
20+
pip install -r requirements.txt
21+
./run.sh
22+
```
23+
24+
`test/.env`
25+
26+
- HOST_NAME: A that you have querywriter access to so setup.py can load data and queries to a subgraph named `graph_algorithms_testing`
27+
- USER_NAME=admin/writer
28+
- PASS=users_pass
29+
30+
`run.sh` does a few things:
31+
32+
- runs `data/create_baseline.py`
33+
- this creates the baselines from the graphs listed in that file
34+
- runs the setup script to make sure the graph is created and data is loaded
35+
- runs the tests with pytest
36+
37+
## Directory layout
38+
39+
Data: stores the satic data for creating graphs, and algorithm baseline results.
40+
41+
- CSV files under `data/[heterogeneous_edges, unweighted_edges, weighted_edges]` store the adjacency information for creating graphs.
42+
- for example `data/weighted_edges/line_edges.csv` stores the edges and weights to create a weighted, line graph.
43+
- JSON files under `data/baseline` store the results for a given algorithm on a given graph type.
44+
- for example `data/baseline/centrality/pagerank/Line_Directed.json` stores the results for pagerank on a directed line graph
45+
46+
test:
47+
48+
- setup.py: creates the graph, loads the data and installs the queries from pyTG's featurizer. Any new/custom queries need to be manually installed
49+
- test<algo_family>.py: houses the testing code for each family of algorithms
50+
51+
```
52+
├── data
53+
│   ├── baseline
54+
│   │   ├── <algo_family>
55+
│   │   │   └── <algo_name>
56+
│   │ │ └── <GraphType>.json
57+
│   ├── <edge_family>
58+
│   │ └── <graph_type>.csv
59+
│   └── create_baseline.py
60+
├── requirements.txt
61+
├── run.sh
62+
├── test
63+
│   ├── pyrightconfig.json
64+
│   ├── setup.py
65+
│   ├── test_centrality.py
66+
│   ├── test_community.py
67+
│   ├── test_path_finding.py
68+
│   ├── test_topological_link_prediction.py
69+
│   └── util.py
70+
```
71+
72+
## Adding tests
73+
74+
Start with the baseline. Add a section or module to `create_baseline.py` that creates a baseline for all the necessary graph types. The outline of the baseline should be written to the correct
75+
baseline path (see above [layout](#directory-layout)).
76+
77+
Add a method to the correct test file (i.e., community algorigthms go in community.py). The first test method in `test/test_centrality.py` is a good template to follow:
78+
79+
```py
80+
# this function will run once for each of the graph names in the undirected_graphs list
81+
@pytest.mark.parametrize("test_name", undirected_graphs)
82+
def test_degree_centrality1(self, test_name):
83+
# query params
84+
params = {
85+
"v_type_set": ["V20"],
86+
"e_type_set": [test_name],
87+
"reverse_e_type_set": [test_name],
88+
"in_degree": True,
89+
"out_degree": False,
90+
"top_k": 100,
91+
"print_results": True,
92+
"result_attribute": "",
93+
"file_path": "",
94+
}
95+
with open(f"data/baseline/centrality/degree_centrality/{test_name}.json") as f:
96+
baseline = json.load(f)
97+
baseline = sorted(baseline[0]["top_scores"], key=lambda x: x["Vertex_ID"])
98+
99+
# call the the algorithm through the featurizer
100+
result = self.feat.runAlgorithm("tg_degree_cent", params=params)
101+
result = sorted(result[0]["top_scores"], key=lambda x: x["Vertex_ID"])
102+
103+
104+
# check that the results agree with the baseline
105+
for b in baseline:
106+
for r in result:
107+
if r["Vertex_ID"] == b["Vertex_ID"] and r["score"] != pytest.approx(
108+
b["score"]
109+
):
110+
pytest.fail(f'{r["score"]} != {b["score"]}')
111+
```
112+
113+
## Available Graphs
114+
115+
Example usage:
116+
117+
- If you want to run a query on a directed, weighted, line graph, use the V20 verts and Line_Directed_Weighted edges.
118+
119+
| Graph | Type | Vertices | Edges |
120+
| --------------------------- | ------------------------------------------------------------ | -------- | -------------------------------- |
121+
| Null | | V0 | |
122+
| Single node | | V1 | |
123+
| Empty graph | Undirected | V20 | Empty |
124+
| | Directed | | Empty_Directed |
125+
| Line | Undirected, unweighted | V20 | Line |
126+
| | Directed, unweighted | | Line_Directed |
127+
| | Undirected, weighted | | Line_Weighted |
128+
| | Directed, weighted | | Line_Directed_Weighted |
129+
| | Heterogeneous vertex types, directed, weighted | V20, V8 | Line_Heterogeneous |
130+
| Ring | Undirected, unweighted | V20 | Ring |
131+
| | Directed, unweighted | | Ring_Directed |
132+
| | Undirected, weighted | | Ring_Weighted |
133+
| | Directed, weighted | | Ring_Directed_Weighted |
134+
| | Heterogeneous vertex types, directed, weighted | V20, V8 | Ring_Heterogeneous |
135+
| Hub & spoke | Undirected, unweighted | V20 | Hub_Spoke |
136+
| | Directed (towards the spokes), unweighted Hub_Spoke_Directed | | |
137+
| | Undirected, weighted Hub_Spoke_Weighted | | |
138+
| | Directed, weighted Hub_Spoke_Directed_Weighted | | |
139+
| | Heterogeneous vertex types, directed, weighted | V20, V8 | Hub_Spoke_Heterogeneous |
140+
| Hub-connected hub & spoke | Undirected, unweighted | V20 | Hub_Connected_Hub_Spoke |
141+
| | Undirected, weighted | | Hub_Connected_Hub_Spoke_Weighted |
142+
| Tree | Undirected, unweighted | V20 | Tree |
143+
| | Directed, unweighted | | Tree_Directed |
144+
| | Undirected, weighted | | Tree_Weighted |
145+
| | Directed, weighted | | Tree_Directed_Weighted |
146+
| | Heterogeneous vertex types, directed, weighted | V20, V8 | Tree_Heterogeneous |
147+
| Complete | Undirected, unweighted | V8 | Complete |
148+
| | Directed, unweighted | | Complete_Directed |
149+
| | Undirected, weighted | | Complete_Weighted |
150+
| | Directed, weighted | | Complete_Directed_Weighted |
151+
| | Heterogeneous vertex types, directed, weighted | V4, V8 | Complete_Heterogeneous |
152+
| DAG | Directed, unweighted | V20 | DAG_Directed |
153+
| | Directed, weighted | | DAG_Directed_Weighted |
154+
| | Heterogeneous vertex types, directed, weighted | V20, V8 | DAG_Heterogeneous |
155+
| Graph with negative cycles | Directed, weighted | V20 | Negative_cycles |
156+
| | Heterogeneous vertex types, directed, weighted | V20, V8 | Negative_Cycle_Heterogeneous |
157+
| Topological link prediction | Unweighted, undirected | V8 | topo_link1 |
158+
| | topo_link2 | | |
159+
| | topo_link3 | | |
160+
| | topo_link4 | | |
161+
| | topo_link5 | | |
162+
| | topo_link6 | | |
163+
| | Unweighted, directed | | topo_link_directed |
164+
| Same Community | no edges | V4 | |

0 commit comments

Comments
 (0)