Skip to content

Commit

Permalink
Merge pull request #17 from alvaradoo/main
Browse files Browse the repository at this point in the history
prod and property graph arachne
  • Loading branch information
zhihuidu authored Apr 14, 2023
2 parents cf5f6bb + bcaea8f commit cc2c848
Show file tree
Hide file tree
Showing 28 changed files with 22,890 additions and 0 deletions.
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,130 @@
GraphServerModules.cfg.*
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
48 changes: 48 additions & 0 deletions arachne/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Arachne: Graph Analysis Extension to Arkouda

## Overview
The Arachne project provides an extension for graph analysis that works with Arkouda. Arachne mimics the NetworkX API while providing high-performance implementations of graph kernels in Chapel.

## Installation
Installation is performed by running `module_configuration.py`. This file is copied from the `Bears-R-Us/arkouda-contrib` repository. When running `module_configuration.py`, the complete path to the location of the Arkouda repo must be specificed through the `ak_loc` flag along with the complete path to the Arkouda contrib repo. In our case, it would be the complete path to this directory housing Arachne. An example follows below:

```
python3 module_configuration.py --ak_loc=/complete/path/to/arkouda/ --pkg_path=/complete/path/to/arkouda-njit/arachne/
```

When the above command completes, the result will be a couple of commands along the lines of:
```
pip install -U /rhome/oaa9/Research/arkouda-njit/arachne/client
cp /rhome/oaa9/Research/arkouda/ServerModules.cfg ~/TmpServerModules.cfg.1681487975
ARKOUDA_SERVER_USER_MODULES=" /rhome/oaa9/Research/arkouda-njit/arachne/server/GraphMsg.chpl" ARKOUDA_CONFIG_FILE=~/TmpServerModules.cfg.1681487975 ARKOUDA_SKIP_CHECK_DEPS=true make -C /rhome/oaa9/Research/arkouda
```

The length of the last command is dependent on the number of modules you have listen inside of `arkouda-njit/arachne/server/ServerModules.cfg`. Within here you can comment in and out the lines of the modules you wish to compile and not compile. By default, all of them are left uncommented.

Next, simply just copy and paste the outputted commands into terminal and your arkouda server should start to build with Arachne added onto it.

If you run into environment errors, you can run the commands below to ensure both Arachne and Arkouda have been pip installed into your environment.
```
pip3 install -e /path/to/arachne/client/.
pip3 install -e /path/to/arkouda/.
```

## Usage
Functions currently available can be found in `client/README.md` with a benchmark file that can be used as a sample found in `benchmarks/bfs.py`. Sample executions of benchmark file follow.

For benchmarking a single graph you can execute:
```
python3 bfs.py node port -f /path/to/arkouda-njit/arachne/data/karate.mtx -t 10
```

For benchmarking a directory of graphs you can execute:
```
python3 bfs.py node01 5554 -d /path/to/arkouda-njit/arachne/data -t 10
```

## Testing
The Arachne tests are executed from the arkouda-njit/arachne directory as follows:
```
python3 -m pytest test/bfs_test.py test/reading_test.py test/class_test.py
```
**Note**: Errors when executing using pytest from arachne directory.
84 changes: 84 additions & 0 deletions arachne/base_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import unittest, os
import arkouda as ak
from server_util.test.server_test_util import get_arkouda_numlocales, start_arkouda_server, \
stop_arkouda_server, TestRunningMode
import importlib

'''
ArkoudaTest defines the base Arkouda test logic for starting up the arkouda_server at the
launch of a unittest TestCase and shutting down the arkouda_server at the completion of
the unittest TestCase.
Note: each Arkouda TestCase class extends ArkoudaTest and encompasses 1..n test methods, the
names of which match the pattern 'test*' (e.g., ArkoudaTest.test_arkouda_server).
'''


class ArkoudaTest(unittest.TestCase):
verbose = True if os.getenv('ARKOUDA_VERBOSE') == 'True' else False
port = int(os.getenv('ARKOUDA_SERVER_PORT', 5555))
server = os.getenv('ARKOUDA_SERVER_HOST', 'localhost')
test_running_mode = TestRunningMode(os.getenv('ARKOUDA_RUNNING_MODE', 'GLOBAL_SERVER'))
timeout = int(os.getenv('ARKOUDA_CLIENT_TIMEOUT', 5))

@classmethod
def setUpClass(cls):
'''
If in full stack mode, configures and starts the arkouda_server process and sets the
ArkoudaTest.server class attribute, noop in client mode.
:return: None
:raise: EnvironmentError if 1..n required test libraries are missing, RuntimeError
if there is an error in configuring or starting arkouda_server
'''
if not importlib.util.find_spec('pytest') or not importlib.util.find_spec('pytest_env'):
raise EnvironmentError('pytest and pytest-env must be installed')
if TestRunningMode.CLASS_SERVER == ArkoudaTest.test_running_mode:
try:
nl = get_arkouda_numlocales()
ArkoudaTest.server, _, _ = start_arkouda_server(numlocales=nl, port=ArkoudaTest.port)
print('Started arkouda_server in TEST_CLASS mode with host: {} port: {} locales: {}'. \
format(ArkoudaTest.server, ArkoudaTest.port, nl))
except Exception as e:
raise RuntimeError('in configuring or starting the arkouda_server: {}, check ' +
'environment and/or arkouda_server installation', e)
else:
print('in client stack test mode with host: {} port: {}'.format(ArkoudaTest.server, ArkoudaTest.port))

def setUp(self):
'''
Connects an Arkouda client for each test case
:return: None
:raise: ConnectionError if exception is raised in connecting to arkouda_server
'''
try:
ak.client.connect(server=ArkoudaTest.server, port=ArkoudaTest.port,
timeout=ArkoudaTest.timeout)
except Exception as e:
raise ConnectionError(e)

def tearDown(self):
'''
Disconnects the client connection for each test case
:return: None
:raise: ConnectionError if exception is raised in connecting to arkouda_server
'''
try:
ak.client.disconnect()
except Exception as e:
raise ConnectionError(e)

@classmethod
def tearDownClass(cls):
'''
Shuts down the arkouda_server started in the setUpClass method if test is run
in full stack mode, noop if in client stack mode.
:return: None
'''
if TestRunningMode.CLASS_SERVER == ArkoudaTest.test_running_mode:
try:
stop_arkouda_server()
except Exception:
pass
Loading

0 comments on commit cc2c848

Please sign in to comment.