diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..4e1ef42 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,31 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b6261a..c3109fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.5.0] - 2020-07-01 +### Added +- package is published to pypi repository ### Changed - new command line syntax: ``` diff --git a/README.md b/README.md index a120f62..b12ec12 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # YSTAFDB -YSTAFDB creates turtle files of the istances of data based on an ontology. The turtle files are needed for the BONSAI knowledge graph. +YSTAFDB creates turtle files of the istances of data based on an ontology. +The turtle files are needed for the BONSAI knowledge graph. The turtle files generated are stored in the BONSAI [rdf repository](https://github.com/BONSAMURAIS/rdf). @@ -10,9 +11,14 @@ Currently generates the following: ## Installation -### with package managers [pip or conda] +### with package manager pip from pypi + +Installable via `pip`: + +``` +pip install ystafdb +``` -Installable via `pip` ### manual Clone git repo @@ -24,11 +30,24 @@ Enter cloned repo ``` $ cd ystafdb ``` -##### Download Base Data -Before progressing the installation, the base ystafdb data must be downloaded, and placed in a folder of your choosing, inside the repo. + +Now install package + +``` +$ python setup.py install +``` + +## Usage + +You must first download the Base Data, and then use `ystafdb-cli` to produce the ttl/nt/xml files. + +### Download Base Data + The data can be downloaded [here](https://www.sciencebase.gov/catalog/file/get/5b9a7c28e4b0d966b485d915?f=__disk__0f%2F58%2Fa7%2F0f58a74db669ee5418f36a698bc85781e867e0ab) as a zip file. -Extract the zip file and move relevant files to a folder. As an example, the data can be placed under `/ystafdb/data/`. -The following ystafdb files are mandatory to have in the folder: + +Extract the contents of the zip file. As an example, the data can be placed under `ystafdb-input`. +The following files from the Base Data are _mandatory_ to have in the folder (`ystafdb-input` in our example): + - `material_names.csv` - `subsystems.csv` - `flows.csv` @@ -37,63 +56,59 @@ The following ystafdb files are mandatory to have in the folder: - `reference_materials.csv` - `reference_timeframes.csv` -##### Create env and install dependencies -Either 1) create new virtualenv and enter shell or 2) enter already existing virtualenv and install dependencies -##### Option 1) -``` -$ pipenv install -$ pipenv shell -``` -##### Option 2) +Under a Linux terminal, you can acomplish the previous two operations with: + ``` -$ source path/to/environment/bin/activate -$ pip install -r requirements.txt +curl -L "https://www.sciencebase.gov/catalog/file/get/5b9a7c28e4b0d966b485d915?f=__disk__0f%2F58%2Fa7%2F0f58a74db669ee5418f36a698bc85781e867e0ab" -o YSTAFDB_CSV_files.zip +unzip -d ystafdb-input YSTAFDB_CSV_files.zip ``` -Now install package +### Generate the ttl or nt or xml files + +If the package is correctly installed, you can use the command line tool `ystafdb-cli` to produce the rdfs as follows: + ``` -$ python setup.py install +$ ystafdb-cli -i -o ``` -## Usage - -### As a command line tool +Where: ++ `` is the location of the ystafdb csv files, and ++ `` is the directory where the output triples graphs will be placed. This is optional, + if not supplied, the output directory will be `output` -If the package is correctly installed, you can use the command line tool `ystafdb-cli` to produce the rdfs as follows: +In the Linux terminal example from above, this would be done with: ``` -$ ystafdb-cli -i -o +ystafdb-cli -i ystafdb-input ``` -Where `` is the location of the ystafdb csv files, and `` is the directory where the output triples graphs will be placed. -The `` directory will have the following content: +The `` directory will have the following contents: ``` output -├── activitytype -│   └── ystafdb -│      └── ystafdb.ttl -├── flowobject -│   └── ystafdb -│      └── ystafdb.ttl -├── location -│   └── ystafdb -│   └── ystafdb.ttl -├── foaf -│   └── ystafdb -│      └── ystafdb.ttl -└── prov -|   └── ystafdb -|   └── ystafdb.ttl -└── flow -   └── ystafdb -    └── huse -    └── huse.ttl - +├── [ 4.0K] activitytype +│   └── [ 4.0K] ystafdb +│   └── [ 249K] ystafdb.ttl +├── [ 4.0K] flow +│   └── [ 4.0K] ystafdb +│   └── [ 4.0K] huse +│   └── [ 41M] huse.ttl +├── [ 4.0K] flowobject +│   └── [ 4.0K] ystafdb +│   └── [ 63K] ystafdb.ttl +├── [ 4.0K] foaf +│   └── [ 4.0K] ystafdb +│   └── [ 1.4K] ystafdb.ttl +├── [ 4.0K] location +│   └── [ 4.0K] ystafdb +│   └── [ 158K] ystafdb.ttl +└── [ 4.0K] prov + └── [ 4.0K] ystafdb + └── [ 1.0M] ystafdb.ttl ``` - ## Contributing -All contributions should be via pull request, do not edit this package directly! We actually use it for stuff. \ No newline at end of file +All contributions should be via pull request, do not edit this package directly! We actually use it for stuff. + diff --git a/setup.py b/setup.py index 0f22d3d..355fd05 100644 --- a/setup.py +++ b/setup.py @@ -16,12 +16,12 @@ # Probably should be changed, __init__.py is no longer required for Python 3 -for dirpath, dirnames, filenames in os.walk('ystafdb'): - # Ignore dirnames that start with '.' - if '__init__.py' in filenames: - pkg = dirpath.replace(os.path.sep, '.') +for dirpath, dirnames, filenames in os.walk("ystafdb"): + # Ignore dirnames that start with "." + if "__init__.py" in filenames: + pkg = dirpath.replace(os.path.sep, ".") if os.path.altsep: - pkg = pkg.replace(os.path.altsep, '.') + pkg = pkg.replace(os.path.altsep, ".") packages.append(pkg) @@ -29,51 +29,41 @@ def package_files(directory): paths = [] for (path, directories, filenames) in os.walk(directory): for filename in filenames: - paths.append(os.path.join('..', path, filename)) + paths.append(os.path.join("..", path, filename)) return paths setup( - name='ystafdb', - version="0.5", + name="ystafdb", + version="0.5.0", packages=packages, + description="CLI tool to parse YSTAFDB and produce ttl/nt/xml.", + long_description=open("README.md").read(), + long_description_content_type="text/markdown", author="Emil Riis Hansen", author_email="emilrh@cs.aau.dk", - license=open('LICENSE').read(), - package_data={'ystafdb': package_files(os.path.join('ystafdb', 'data'))}, + package_data={"ystafdb": package_files(os.path.join("ystafdb", "data"))}, # Only if you have non-python data (CSV, etc.). Might need to change the directory name as well. - # package_data={'your_name_here': package_files(os.path.join('your_library_name', 'data'))}, - entry_points = { - 'console_scripts': [ - 'ystafdb-cli = ystafdb.bin.ystafdb:main', - ] - }, - install_requires=[ - 'appdirs', - 'docopt', - 'rdflib', - 'pandas' - ], + # package_data={"your_name_here": package_files(os.path.join("your_library_name", "data"))}, + entry_points={"console_scripts": ["ystafdb-cli = ystafdb.bin.ystafdb:main",]}, + install_requires=["appdirs", "docopt", "rdflib", "pandas"], url="https://github.com/BONSAMURAIS/ystafdb/", - long_description_content_type='text/markdown', - long_description=open('README.md').read(), - description='', classifiers=[ - 'Intended Audience :: End Users/Desktop', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Scientific/Engineering :: Information Analysis', - 'Topic :: Scientific/Engineering :: Mathematics', - 'Topic :: Scientific/Engineering :: Visualization', + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Topic :: Scientific/Engineering :: Information Analysis", + "Topic :: Scientific/Engineering :: Mathematics", + "Topic :: Scientific/Engineering :: Visualization", ], )