Skip to content

Commit

Permalink
Merge pull request #2 from ContinuumIO/modernize
Browse files Browse the repository at this point in the history
Modernize versioning and build
  • Loading branch information
jbcrail committed Apr 18, 2018
2 parents 763d576 + c015b13 commit 751b398
Show file tree
Hide file tree
Showing 12 changed files with 2,412 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
intake_netflow/_version.py export-subst
18 changes: 14 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,22 @@ install:
- |
echo "Configuring conda."
source $HOME/miniconda3/bin/activate root
conda install -y conda-build anaconda-client
conda install -y conda-build anaconda-client flake8
script:
- conda build -c "https://conda.anaconda.org/t/$ANACONDA_TOKEN/intake" ./conda
- if [[ -n "${TRAVIS_TAG}" && "${CONDA_PY}" = "36" ]]; then anaconda -t "${ANACONDA_TOKEN}"
upload -u intake --force `conda build -c intake/label/main --output ./conda`; fi
- |
flake8 .
conda build -c intake -c defaults -c conda-forge ./conda
- |
if [ "$CONDA_PY" = "36" && "$TRAVIS_OS_NAME" = "linux" ]; then
if [ -n "$TRAVIS_TAG" ]; then
# If tagged git version, upload package to main channel
anaconda -t ${ANACONDA_TOKEN} upload -u intake --force `conda build --output ./conda`
else
# Otherwise upload package to dev channel
anaconda -t ${ANACONDA_TOKEN} upload -u intake --label dev --force `conda build --output ./conda`
fi
fi
notifications:
email: false
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include versioneer.py
include intake_netflow/_version.py
4 changes: 2 additions & 2 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package:
name: intake-netflow
version: 0.0.1
version: {{ GIT_DESCRIBE_TAG }}

source:
path: ..

build:
number: 0
number: {{ GIT_DESCRIBE_NUMBER }}
script:
- python setup.py install --single-version-externally-managed --record=record.txt
noarch: python
Expand Down
3 changes: 0 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,3 @@
author, 'intake_netflow', 'One line description of project.',
'Miscellaneous'),
]



39 changes: 5 additions & 34 deletions intake_netflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from dask.bytes import open_files

from intake.source import base

from .v9 import RecordStream
from ._version import get_versions

__version__ = get_versions()['version']
del get_versions


class Plugin(base.Plugin):
Expand All @@ -17,36 +18,6 @@ def open(self, urlpath, **kwargs):
urlpath : str
Location of the data files; can include protocol and glob characters.
"""
from .source import NetflowSource
base_kwargs, source_kwargs = self.separate_base_kwargs(kwargs)
return NetflowSource(urlpath=urlpath, metadata=base_kwargs['metadata'])


class NetflowSource(base.DataSource):
def __init__(self, urlpath, metadata=None):
"""Source to load Cisco Netflow packets as sequence of Python dicts.
Parameters:
urlpath : str
Location of the data files; can include protocol and glob characters.
"""
self._urlpath = urlpath
self._streams = open_files(urlpath, mode='rb')

super(NetflowSource, self).__init__(container='python', metadata=metadata)

def _get_schema(self):
return base.Schema(datashape=None,
dtype=None,
shape=None,
npartitions=len(self._streams),
extra_metadata={})

def _get_partition(self, i):
with self._streams[i] as f:
return list(RecordStream(f))

def _close(self):
for stream in self._streams:
stream.close()

self._streams = None

0 comments on commit 751b398

Please sign in to comment.