Skip to content
Snippets Groups Projects
Commit af4d4866 authored by Mattia Mancini's avatar Mattia Mancini
Browse files

Fix tests and setup.py

parent 2215bc3e
No related branches found
No related tags found
No related merge requests found
Pipeline #13144 canceled
......@@ -4,3 +4,5 @@ dist
*.egg*
env
venv
**/__pycache__/
.tox
# This file is a template, and might need editing before it works on your project.
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: python:latest
stages:
- test
- build
- publish
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
paths:
- .cache/pip
- venv/
before_script:
- python -V # Print out python version for debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install twine
- pip install -r requirements.txt
test:
stage: test
script:
- python setup.py test
build:
stage: build
script:
- python setup.py bdist_wheel
upload:
stage: publish
retry: 2
allow_failure: true
script:
- python setup.py sdist bdist_wheel
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --verbose --repository-url https://git.astron.nl/api/v4/projects/${CI_PROJECT_ID}/packages/pypi dist/*
artifacts:
paths:
- dist/*.whl
#!/usr/bin/env python3
from argparse import ArgumentParser
from lofar.lta.sip.validator import main
import sys
def parse_args():
parser = ArgumentParser(description='validates sip over the xsd')
parser.add_argument('sip', help='xml sip to validate')
return parser.parse_args()
if __name__ == '__main__':
main(sys.argv[1])
args = parse_args()
main(args.sip)
File moved
import pkg_resources
from lxml import etree
import os
from . import ltasip
d = os.path.dirname(os.path.realpath(__file__))
XSDPATH = d+"/LTA-SIP.xsd"
DEFAULT_SIP_XSD_PATH = pkg_resources.resource_string(__name__, "etc/LTA-SIP.xsd")
DEFAULT_SIP_XSD_PATH = os.path.join(os.environ.get('LOFARROOT', '/opt/lofar'), 'etc', 'lta', 'LTA-SIP.xsd')
def validate(xmlpath, xsdpath=DEFAULT_SIP_XSD_PATH):
'''validates given xml file against given xsd file'''
......@@ -44,7 +42,6 @@ def check_consistency(xmlpath):
xml = f.read()
sip = ltasip.CreateFromDocument(xml)
linkstodataproduct = {}
linkstoprocess = {}
......@@ -79,20 +76,22 @@ def check_consistency(xmlpath):
id_unspec = str(unspec.processIdentifier.identifier)
linkstoprocess.setdefault(id_unspec, [])
# todo: online processing
# todo: parsets (?)
for id in linkstodataproduct:
for id_from in linkstodataproduct.get(id):
if not id_from in linkstoprocess:
raise Exception("The pipeline or observation that created dataproduct '"+ id + "' seems to be missing! -> ", id_from)
raise Exception(
"The pipeline or observation that created dataproduct '" + id + "' seems to be missing! -> ",
id_from)
for id in linkstoprocess:
for ids_from in linkstoprocess.get(id):
for id_from in ids_from:
if not id_from in linkstodataproduct:
raise Exception("The input dataproduct for pipeline '"+ id +"' seems to be missing! -> ", id_from)
raise Exception("The input dataproduct for pipeline '" + id + "' seems to be missing! -> ",
id_from)
print("General SIP structure seems ok!")
return True # already raised Exception if there was a problem...
......
......@@ -11,15 +11,26 @@ scripts = glob.glob('bin/*')
setuptools.setup(
name="siputils",
version="0.0.1",
version="0.4",
version_config={
"template": "{tag}",
"dev_template": "{tag}.dev{ccount}+git.{sha}",
"dirty_template": "{tag}.dev{ccount}+git.{sha}.dirty",
"starting_version": "0.0.1",
"version_callback": None,
"version_file": 'version',
"count_commits_from_version_file": True
},
author="Mattia Mancini",
author_email="mancini@astron.nl",
description="LTA sip utils",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://git.astron.nl/ro/siputils",
packages=setuptools.find_packages(),
data_files = [('etc/lta/', ['etc/LTA-SIP.xsd'])],
packages=['lofar.lta.sip'],
package_dir={'lofar.lta.sip': 'lib'},
package_data = {'lofar.lta.sip': ['etc/*.xsd']},
include_package_data=False,
scripts=scripts,
classifiers=[
"Programming Language :: Python :: 3",
......@@ -28,7 +39,14 @@ setuptools.setup(
],
python_requires='>=3.6',
install_requires = [
'pyxb',
'pyxb==1.2.5',
'lxml',
'requests',
'graphviz'
],
tests_require=['pytest'],
setup_requires = [
'setuptools-git-versioning'
],
test_suite='test',
)
[tox]
envlist = py37
[testenv]
# install testing framework
# ... or install anything else you might need here
deps = pytest
# run the tests
# ... or run any other command line tool you need to run here
commands = pytest
0.4
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment