Skip to content

Commit

Permalink
Merge pull request #172 from mattjala/github_ci
Browse files Browse the repository at this point in the history
Add test workflow to Github
  • Loading branch information
mattjala authored Mar 25, 2024
2 parents fdf1e40 + 8f50278 commit f69f3c6
Show file tree
Hide file tree
Showing 72 changed files with 1,169 additions and 1,108 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: h5pyd CI

on:
push:
pull_request:
branches: [master]

env:
ADMIN_PASSWORD: admin
ADMIN_USERNAME: admin
USER_NAME: test_user1
USER_PASSWORD: test
USER2_NAME: test_user2
USER2_PASSWORD: test
HSDS_USERNAME: test_user1
HSDS_PASSWORD: test
HSDS_ENDPOINT: http+unix://%2Ftmp%2Fhs%2Fsn_1.sock
ROOT_DIR: ${{github.workspace}}/hsds/hsds_root
BUCKET_NAME: hsds_bucket
HS_ENDPOINT: http+unix://%2Ftmp%2Fhs%2Fsn_1.sock
H5PYD_TEST_FOLDER: /home/test_user1/h5pyd_tests/

jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest,]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
shell: bash
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # stop the build if there are Python syntax errors or undefined names
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
- name: Install package
shell: bash
run: |
pip install -e .
- name: Checkout HSDS
uses: actions/checkout@v3
with:
repository: HDFGroup/hsds
path: ${{github.workspace}}/hsds

- name: Install HSDS
shell: bash
run: |
cd ${{github.workspace}}/hsds
pip install -e .
- name: Start HSDS
shell: bash
run: |
cd ${{github.workspace}}/hsds
mkdir hsds_root
mkdir hsds_root/hsds_bucket
cp admin/config/groups.default admin/config/groups.txt
cp admin/config/passwd.default admin/config/passwd.txt
./runall.sh --no-docker 1 &
sleep 11 # let the nodes get ready
python tests/integ/setup_test.py
- name: Create h5pyd test folder
shell: bash
run: |
HS_USERNAME=test_user1 HS_PASSWORD=test TEST2_USERNAME=test_user1 TEST2_PASSWORD=test hstouch -v /home/test_user1/h5pyd_tests/
- name: Run h5pyd tests
shell: bash
run: |
HS_USERNAME=test_user1 HS_PASSWORD=test TEST2_USERNAME=test_user1 TEST2_PASSWORD=test python testall.py
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.intersphinx',
'sphinx.ext.extlinks',
'sphinx.ext.mathjax',
'sphinx.ext.intersphinx',
'sphinx.ext.extlinks',
'sphinx.ext.mathjax',
]

# intersphinx_mapping = {'low': ('https://api.h5py.org', None)}
Expand Down
8 changes: 4 additions & 4 deletions examples/read_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

import h5pyd as h5py


def visit_item(name):
print("visit:", name)
return None


def find_g1_2(name):
print("visit:", name)
if name.endswith("g1.2"):
Expand All @@ -26,12 +28,13 @@ def visit_item_obj(name, obj):
print("visit:", name, obj.id.id)
return None


print("version:", h5py.version.version)

# this is the path specified in the "post-install instructions"
# see: "Test Data Setup" in:
# https://github.com/HDFGroup/hsds/blob/master/docs/post_install.md
DOMAIN_PATH="/home/test_user1/test/tall.h5"
DOMAIN_PATH = "/home/test_user1/test/tall.h5"
print("opening domain:", DOMAIN_PATH)

f = h5py.File(DOMAIN_PATH, "r")
Expand Down Expand Up @@ -85,6 +88,3 @@ def visit_item_obj(name, obj):

print("search g1.2:")
f.visit(find_g1_2)



3 changes: 1 addition & 2 deletions examples/write_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
CHUNKS = (1500, 275)



if len(sys.argv) == 1 or sys.argv[1] in ("-h", "--help"):
s = f"usage: python {sys.argv[0]} "
s += "[--ncols=n] "
Expand Down Expand Up @@ -138,4 +137,4 @@
else:
print("passed!")

f.close()
f.close()
4 changes: 2 additions & 2 deletions h5pyd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@


__doc__ = \
"""
"""
This is the h5pyd package, a Python interface to the HDF REST Server.
Version %s
""" % (version.version)
""" % (version.version)


def enable_ipython_completer():
Expand Down
39 changes: 14 additions & 25 deletions h5pyd/_apps/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"flags": ["--api_key",],
"help": "user api key",
"choices": ["API_KEY"]
},
},
"hs_bucket": {
"default": None,
"flags": ["--bucket",],
Expand Down Expand Up @@ -67,11 +67,12 @@
"default": False,
"flags": ["--ignore",],
"help": "don't exit on error"
}
}
}

hscmds = ("hsinfo", "hsconfigure", "hsls", "hstouch", "hsload", "hsget", "hsacl", "hsrm", "hsdiff")


class Config:
"""
User Config state
Expand Down Expand Up @@ -163,7 +164,7 @@ def setitem(self, name, value, flags=None, choices=None, help=None):
""" Set a config item """
if name not in self._names:
self._names.append(name)
self._values[name] = value
self._values[name] = value
if flags is not None:
self._flags[name] = flags
for flag in flags:
Expand All @@ -175,7 +176,7 @@ def setitem(self, name, value, flags=None, choices=None, help=None):

def __setitem__(self, name, value):
self.setitem(name, value)

def __len__(self):
return len(self._names)

Expand Down Expand Up @@ -212,35 +213,33 @@ def get_see_also(self, this_cmd):
msg += f"{cmd}, "
msg = msg[:-2] # remove trailing comma
return msg


def get_help_message(self, name):
help_text= self.get_help(name)
help_text = self.get_help(name)
flags = self.get_flags(name)
choices = self.get_choices(name)
if not help_text or len(flags) == 0:
return None

msg = flags[0]
for i in range(1, len(flags)):
msg += f", {flags[i]}"
if choices:
if len(choices) == 1:
msg += f" {choices[0]}"
else:
msg += " {"
msg += " {"
for choice in choices:
msg += f"{choice}|"
msg = msg[:-1]
msg += "}"
if len(msg) < 40:
pad = " "*(40 - len(msg))
pad = " " * (40 - len(msg))
msg += pad

msg += f" {help_text}"

return msg


def get_nargs(self, name):
choices = self._choices.get(name)
Expand All @@ -260,15 +259,15 @@ def get_names(self):

def set_cmd_flags(self, args, allow_post_flags=False):
""" process any command line options
return any place argument as a list
return any place argument as a list
"""
options = []
argn = 0
while argn < len(args):
arg = args[argn]
val = None
if len(args) > argn + 1:
val = args[argn+1]
val = args[argn + 1]
if not arg.startswith("-"):
options.append(arg)
argn += 1
Expand Down Expand Up @@ -299,7 +298,7 @@ def set_cmd_flags(self, args, allow_post_flags=False):
self._values[name] = val
argn += 2
return options

def get_loglevel(self):
val = self._values["loglevel"]
val = val.upper()
Expand Down Expand Up @@ -329,13 +328,3 @@ def print(self, msg):
logging.info(msg)
if self._values.get("verbose"):
print(msg)










Loading

0 comments on commit f69f3c6

Please sign in to comment.