From 98215c3100b8c76c5588e4f1f3d1fccf9212fb35 Mon Sep 17 00:00:00 2001 From: jlaura Date: Thu, 26 Aug 2021 12:59:50 -0700 Subject: [PATCH] Updates minor bugs in jig update and affine transform (#590) * Updates minor bugs in jig update and affine transform * Updates changelog and bumps bug version * updates to use CI for version bumping --- .github/workflows/version_bump.yml | 66 ++++++++++++++++++++++++++++++ CHANGELOG.md | 6 +++ autocnet/graph/network.py | 4 +- autocnet/io/db/controlnetwork.py | 17 ++++---- autocnet/matcher/subpixel.py | 2 +- conda/meta.yaml | 2 +- setup.py | 22 ++-------- 7 files changed, 89 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/version_bump.yml diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml new file mode 100644 index 00000000..b7017ec8 --- /dev/null +++ b/.github/workflows/version_bump.yml @@ -0,0 +1,66 @@ +name: Autobump + +on: + pull_request: + types: [closed] + +jobs: + label-version-bump: + runs-on: ubuntu-latest + if: | + github.event.pull_request.merged + && ( + contains(github.event.pull_request.labels.*.name, 'bump patch') + || contains(github.event.pull_request.labels.*.name, 'bump minor') + || contains(github.event.pull_request.labels.*.name, 'bump major') + ) + steps: + - name: Check out the repository + uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.base.ref }} + + - name: Detect version bump type + id: bump-type + run: | + BUMP_TYPE=null + if [[ $BUMP_PATCH_PRESENT == 'true' ]]; then + BUMP_TYPE=patch + fi + if [[ $BUMP_MINOR_PRESENT == 'true' ]]; then + BUMP_TYPE=minor + fi + if [[ $BUMP_MAJOR_PRESENT == 'true' ]]; then + BUMP_TYPE=major + fi + echo "::set-output name=bump-type::$BUMP_TYPE" + env: + BUMP_PATCH_PRESENT: ${{ contains(github.event.pull_request.labels.*.name, 'bump patch') }} + BUMP_MINOR_PRESENT: ${{ contains(github.event.pull_request.labels.*.name, 'bump minor') }} + BUMP_MAJOR_PRESENT: ${{ contains(github.event.pull_request.labels.*.name, 'bump major') }} + + - name: Determine new version + id: new-version + if: steps.bump-type.outputs.bump-type != 'null' + run: | + CURRENT_VERSION='python setup.py --version' + if ${BUMP_TYPE} == 'major' + then + NEW_VERSION=`IFS='.' read -ra SPLITVER <<< "$VERSION"; echo $(("${SPLITVER[0]}"+1))."${SPLITVER[1]}"."${SPLITVER[2]}";` + elif ${BUMP_TYPE} == 'minor' + NEW_VERSION=`IFS='.' read -ra SPLITVER <<< "$VERSION"; echo "${SPLITVER[0]}".$(("${SPLITVER[1]}"+1))."${SPLITVER[2]}";` + elif ${BUMP_TYPE} == 'patch' + NEW_VERSION=`IFS='.' read -ra SPLITVER <<< "$VERSION"; echo "${SPLITVER[0]}"."${SPLITVER[1]}".$(("${SPLITVER[2]}"+1));` + fi + - name: Update version in setup.py + if: steps.bump-type.outputs.bump-type != 'null' + run: sed -i "s/$CURRENT_VERSION/$NEW_VERSION/g" setup.py + - name: Update version in meta.yaml + if: steps.bump-type.outputs.bump-type != 'null' + run: sed -i "s/$CURRENT_VERSION/$NEW_VERSION/g" conda/meta.yaml + - name: Commit bump + if: steps.bump-type.outputs.bump-type != 'null' + uses: EndBug/add-and-commit@v7 + with: + branch: ${{ github.event.pull_request.base.ref }} + message: 'Bump version to ${{ steps.new-version.outputs.new-version }}' \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e00f872..c7394a61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,12 @@ release. ### Added - Added a mutual information matcher [#559](https://github.com/USGS-Astrogeology/autocnet/pull/559) +### Changed +- `geom_match_simple` defaults to a 3rd order warp for interpolation + +### Fixed +- `update_from_jigsaw` failures due to stale code. Now uses a conntext on the engine to ensure closure + ## [0.6.0] ### Added diff --git a/autocnet/graph/network.py b/autocnet/graph/network.py index 1c19e19e..d29c9b46 100644 --- a/autocnet/graph/network.py +++ b/autocnet/graph/network.py @@ -1938,8 +1938,8 @@ class NetworkCandidateGraph(CandidateGraph): """ isis_network = cnet.from_isis(path) io_controlnetwork.update_from_jigsaw(isis_network, - ncg.measures, - ncg.connection, + self.measures, + self.engine, pointid_func=pointid_func) @classmethod diff --git a/autocnet/io/db/controlnetwork.py b/autocnet/io/db/controlnetwork.py index 96a59cb3..8282a677 100644 --- a/autocnet/io/db/controlnetwork.py +++ b/autocnet/io/db/controlnetwork.py @@ -98,7 +98,7 @@ ORDER BY measures."pointid", measures."id"; return df -def update_from_jigsaw(cnet, measures, connection, pointid_func=None): +def update_from_jigsaw(cnet, measures, engine, pointid_func=None): """ Updates a database fields: liner, sampler, measureJigsawRejected, samplesigma, and linesigma using an ISIS control network. @@ -120,8 +120,8 @@ def update_from_jigsaw(cnet, measures, connection, pointid_func=None): measures : pd.DataFrame of measures from a database table. - connection : object - An SQLAlchemy DB connection object + engine : object + An SQLAlchemy DB engine object poitid_func : callable A callable function that is used to split the id string in @@ -174,12 +174,13 @@ def update_from_jigsaw(cnet, measures, connection, pointid_func=None): # Compute the residual from the components measures['residual'] = np.sqrt(measures['liner'] ** 2 + measures['sampler'] ** 2) - # Execute an SQL COPY from a CSV buffer into the DB - measures.to_sql('measures_tmp', connection, schema='public', if_exists='replace', index=False, method=copy_from_method) + with engine.connect() as connection: + # Execute an SQL COPY from a CSV buffer into the DB + measures.to_sql('measures_tmp', connection, schema='public', if_exists='replace', index=False, method=copy_from_method) - # Drop the old measures table and then rename the tmp measures table to be the 'new' measures table - connection.execute('DROP TABLE measures;') - connection.execute('ALTER TABLE measures_tmp RENAME TO measures;') + # Drop the old measures table and then rename the tmp measures table to be the 'new' measures table + connection.execute('DROP TABLE measures;') + connection.execute('ALTER TABLE measures_tmp RENAME TO measures;') # This is not a permanent placement for this function # TO DO: create a new module for parsing/cleaning points from a controlnetwork diff --git a/autocnet/matcher/subpixel.py b/autocnet/matcher/subpixel.py index 1a362d13..3f8e1a4b 100644 --- a/autocnet/matcher/subpixel.py +++ b/autocnet/matcher/subpixel.py @@ -922,7 +922,7 @@ def geom_match_simple(base_cube, box = (0, 0, max(dst_arr.shape[1], base_arr.shape[1]), max(dst_arr.shape[0], base_arr.shape[0])) dst_arr = np.array(Image.fromarray(dst_arr).crop(box)) - dst_arr = tf.warp(dst_arr, affine) + dst_arr = tf.warp(dst_arr, affine, order=3) t3 = time.time() print(f'Affine warp took {t3-t2} seconds.') if verbose: diff --git a/conda/meta.yaml b/conda/meta.yaml index 92422458..eabb392f 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,6 +1,6 @@ package: name: autocnet - version: 0.6 + version: 0.6.1 channels: - conda-forge diff --git a/setup.py b/setup.py index 06697bfe..09f30d41 100755 --- a/setup.py +++ b/setup.py @@ -1,39 +1,25 @@ import os from setuptools import setup, find_packages -import autocnet -from glob import glob - -from autocnet.examples import available #Grab the README.md for the long description with open('README.md', 'r') as f: long_description = f.read() -def setup_package(): - examples = set() - for i in available(): - if not os.path.isdir('autocnet/examples/' + i): - if '.' in i: - glob_name = 'examples/*.' + i.split('.')[-1] - else: - glob_name = 'examples/' + i - else: - glob_name = 'examples/' + i + '/*' - examples.add(glob_name) +__version__ = '0.6.1' +def setup_package(): setup( name = "autocnet", - version = '0.6.0', + version = __version__, author = "Jay Laura", author_email = "jlaura@usgs.gov", - description = ("I/O API to support planetary data formats."), + description = ("Automated control network generation."), long_description = long_description, license = "Public Domain", keywords = "Multi-image correspondence detection", url = "http://packages.python.org/autocnet", packages=find_packages(), include_package_data=True, - package_data={'autocnet' : list(examples)}, zip_safe=False, install_requires=[], classifiers=[ -- GitLab