Skip to content

Commit

Permalink
remove strategy (#16)
Browse files Browse the repository at this point in the history
* remove strategy

* change github install-poetry action

* fix github action cache
  • Loading branch information
tk2lab authored Nov 6, 2020
1 parent 7347db1 commit de6cd68
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,30 @@ jobs:
python-version: [3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Check out repository
uses: actions/checkout@v2

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

- name: Install Poetry
uses: dschep/[email protected]
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache Poetry virtualenv
id: cached-poetry-dependencies
uses: actions/cache@v2
id: cache
with:
path: ~/.cache
key: poetry-${{ hashFiles('**/poetry.lock') }}
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Decendencies
run: poetry install
if: steps.cache.outputs.cache-hit != 'true'
if: steps.cached-poetry-dependences.outputs.cache-hit != 'true'

- name: Run pytest
run: poetry run pytest tests
16 changes: 10 additions & 6 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,30 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Check out repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install Poetry
uses: dschep/[email protected]
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache Poetry virtualenv
id: cached-poetry-dependencies
uses: actions/cache@v2
id: cache
with:
path: ~/.cache
key: poetry-${{ hashFiles('**/poetry.lock') }}
path: .venv
key: venv-${{ runner.os}}-${{ hashFiles('**/poetry.lock') }}

- name: Install Decendencies
run: poetry install
if: steps.cache.outputs.cache-hit != 'true'
if: steps.cached-poetroy-dependencies.outputs.cache-hit != 'true'

- name: Build and Publish
run: |
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hotaru"
version = "3.3.1"
version = "3.3.2"
description = "High performance Optimizer to extract spike Timing And cell location from calcium imaging data via lineaR impUlse"
license = "GPL-3.0-only"
authors = ["TAKEKAWA Takashi <[email protected]>"]
Expand Down
4 changes: 1 addition & 3 deletions src/hotaru/footprint/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@


def clean_footprint(data, mask, gauss, radius, batch, verbose):
strategy = tf.distribute.get_strategy()

dataset = tf.data.Dataset.from_tensor_slices(data)
dataset = unmasked(dataset, mask)
dataset = dataset.batch(batch)
Expand All @@ -27,7 +25,7 @@ def clean_footprint(data, mask, gauss, radius, batch, verbose):
ps = tf.TensorArray(tf.int32, nk)
fs = tf.TensorArray(tf.float32, nk)
i = tf.constant(0)
for data in strategy.experimental_distribute_dataset(dataset):
for data in dataset:
gl, ll, rl, yl, xl = _prepare(data, mask, gauss, radius)
nx = tf.size(rl)
for k in tf.range(nx):
Expand Down
4 changes: 1 addition & 3 deletions src/hotaru/footprint/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@


def make_segment(dataset, mask, gauss, radius, peaks, shard, batch, verbose):
strategy = tf.distribute.get_strategy()

ts, rs, ys, xs = peaks[:, 0], peaks[:, 1], peaks[:, 2], peaks[:, 3]
nk = ts.size

Expand All @@ -29,7 +27,7 @@ def make_segment(dataset, mask, gauss, radius, peaks, shard, batch, verbose):
prog = tf.keras.utils.Progbar(nk, verbose=verbose)
fps = tf.TensorArray(tf.float32, 0, True)
e = K.constant(0, tf.int32)
for imgs in strategy.experimental_distribute_dataset(dataset):
for imgs in dataset:
s, e = e, e + tf.shape(imgs)[0]
gl, yl, xl = _prepare(
imgs, s, e, ts, rs, ys, xs, gauss, radius,
Expand Down

0 comments on commit de6cd68

Please sign in to comment.