Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into merge-from-upstre…
Browse files Browse the repository at this point in the history
…am-master
  • Loading branch information
huy-nguyen committed Jul 20, 2023
2 parents 829e0b0 + c6e6da5 commit c7cf26b
Show file tree
Hide file tree
Showing 76 changed files with 3,080 additions and 806 deletions.
19 changes: 19 additions & 0 deletions .github/actions/setup-firefox/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Setup firefox"
description: "Sets up firefox on Linux"
runs:
using: "composite"
steps:
- run: |
sudo add-apt-repository ppa:mozillateam/ppa
echo '
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
Package: firefox
Pin: version 1:1snap1-0ubuntu2
Pin-Priority: -1
' | sudo tee /etc/apt/preferences.d/mozilla-firefox
sudo apt-get install firefox xvfb
if: startsWith(runner.os, 'Linux')
shell: bash
252 changes: 252 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
name: Build

on: [push, pull_request]

jobs:
client:
strategy:
matrix:
node-version:
- '16.x'
os:
- 'ubuntu-latest'
- 'windows-latest'
- 'macos-latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ matrix.node-version }}-node_modules-${{ hashFiles('**/package-lock.json') }}
- run: npm install
- name: Typecheck with TypeScript
run: npm run typecheck
- name: Build client bundles
run: npm run build -- --no-typecheck
- name: Build JavaScript module
run: npm run build-module -- --no-typecheck
- name: Build Python client bundles
run: npm run build-python -- --no-typecheck
- uses: ./.github/actions/setup-firefox
- name: Run JavaScript tests (including WebGL)
# Swiftshader, used by Chrome headless, crashes when running Neuroglancer
# tests.
#
# The only reliable headless configuration is Firefox on Linux under
# xvfb-run, which uses Mesa software rendering.
if: startsWith(runner.os, 'Linux')
run: xvfb-run --auto-servernum --server-args='-screen 0 1024x768x24' npm run test -- --browsers Firefox
- name: Run JavaScript tests (excluding WebGL)
if: ${{ !startsWith(runner.os, 'Linux') }}
run: npm run test -- --browsers ChromeHeadless --define=NEUROGLANCER_SKIP_WEBGL_TESTS
- name: Run JavaScript benchmarks
run: npm run benchmark

# Builds Python package and runs Python tests
#
# On ubuntu-latest, this also runs browser-based tests. On Mac OS and
# Windows, this only runs tests that do not require a browser, since a working
# headless WebGL2 implementation is not available on Github actions.
python-tox:
strategy:
matrix:
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
node-version:
- '16.x'
os:
- 'ubuntu-latest'
- 'windows-latest'
- 'macos-latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
# Need full history to determine version number.
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ matrix.node-version }}-node_modules-${{ hashFiles('**/package-lock.json') }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('setup.py') }}
# Uncomment the action below for an interactive shell
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Install Python packaging/test tools
run: python -m pip install --upgrade pip tox wheel numpy pytest
- uses: ./.github/actions/setup-firefox
- name: Test with tox
run: tox -e ${{ fromJSON('["skip-browser-tests","firefox-xvfb"]')[runner.os == 'Linux'] }}
env:
TOX_TESTENV_PASSENV: GH_TOKEN
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Verify that editable install works
- name: Install in editable form
run: pip install -e . --config-settings editable_mode=strict
- name: Run Python tests against editable install (excluding WebGL)
working-directory: python/tests
run: pytest -vv --skip-browser-tests

python-build-package:
strategy:
matrix:
include:
- os: 'ubuntu-latest'
cibw_build: '*'
wheel_identifier: 'linux'
node-version: '16.x'
- os: 'windows-latest'
cibw_build: '*'
wheel_identifier: 'windows'
node-version: '16.x'
- os: 'macos-latest'
cibw_build: '*_x86_64'
wheel_identifier: 'macos_x86_64'
node-version: '16.x'
- os: 'macos-latest'
cibw_build: '*_arm64'
wheel_identifier: 'macos_arm64'
node-version: '16.x'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
# Need full history to determine version number.
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ matrix.node-version }}-node_modules-${{ hashFiles('**/package-lock.json') }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-buildwheel-${{ hashFiles('setup.py') }}
- run: npm install
- run: |
build_info="{'tag':'$(git describe --always --tags)', 'url':'https://github.com/google/neuroglancer/commit/$(git rev-parse HEAD)', 'timestamp':'$(date)'}"
npm run build-python -- --no-typecheck --define NEUROGLANCER_BUILD_INFO="${build_info}"
shell: bash
- name: Check for dirty working directory
run: git diff --exit-code
- name: Build Python source distribution (sdist)
run: python setup.py sdist --format gztar
if: ${{ runner.os == 'Linux' }}
- name: Install cibuildwheel
run: pip install cibuildwheel
- name: Build Python wheels
run: bash -xve ./python/build_tools/cibuildwheel.sh
env:
# On Linux, share pip cache with manylinux docker containers
CIBW_ENVIRONMENT_LINUX: PIP_CACHE_DIR=/host${{ steps.pip-cache.outputs.dir }}
CIBW_BEFORE_ALL_LINUX: /project/python/build_tools/cibuildwheel_linux_cache_setup.sh /host${{ steps.pip-cache.outputs.dir }}
CIBW_BUILD: ${{ matrix.cibw_build }}
- name: Upload wheels as artifacts
uses: actions/upload-artifact@v2
with:
name: python-wheels-${{ matrix.wheel_identifier }}
path: |
dist/*.whl
dist/*.tar.gz
python-publish-package:
# Only publish package on push to tag or default branch.
if: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master') }}
runs-on: ubuntu-latest
needs:
- 'python-build-package'
steps:
- uses: actions/download-artifact@v2
with:
name: python-wheels-linux
path: dist
- uses: actions/download-artifact@v2
with:
name: python-wheels-macos_x86_64
path: dist
- uses: actions/download-artifact@v2
with:
name: python-wheels-macos_arm64
path: dist
- uses: actions/download-artifact@v2
with:
name: python-wheels-windows
path: dist
# - name: Publish to PyPI (test server)
# uses: pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806 # 2020-09-25
# with:
# user: __token__
# password: ${{ secrets.pypi_test_token }}
- name: Publish to PyPI (main server)
uses: pypa/gh-action-pypi-publish@54b39fb9371c0b3a6f9f14bb8a67394defc7a806 # 2020-09-25
with:
user: __token__
password: ${{ secrets.pypi_token }}
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
ngauth:
strategy:
matrix:
go-version: ['1.19']
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup go ${{ matrix.go-version }}
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
- run: go build .
working-directory: ngauth_server
wasm:
# Ensures that .wasm files are reproducible.
strategy:
matrix:
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: ./src/neuroglancer/mesh/draco/build.sh
- run: ./src/neuroglancer/sliceview/compresso/build.sh
- run: ./src/neuroglancer/sliceview/png/build.sh
# Check that there are no differences.
- run: git diff --exit-code
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ The four-pane view consists of 3 orthogonal cross-sectional views as well as a 3

This dataset was copied from <https://www.janelia.org/project-team/flyem/data-and-software-release>, and is made available under the [Open Data Common Attribution License](http://opendatacommons.org/licenses/by/1.0/). Paper: <a href="http://dx.doi.org/10.1073/pnas.1509820112" target="_blank">Takemura, Shin-ya et al. "Synaptic Circuits and Their Variations within Different Columns in the Visual System of Drosophila." Proceedings of the National Academy of Sciences of the United States of America 112.44 (2015): 13711-13716.</a>

- Example of viewing 2D microscopy (coronal section of rat brain at 325 nanometer resolution). <a href="https://neuroglancer-demo.appspot.com/#!%7B%22dimensions%22:%7B%22x%22:%5B1e-9%2C%22m%22%5D%2C%22y%22:%5B1e-9%2C%22m%22%5D%7D%2C%22position%22:%5B10387071%2C5347131%5D%2C%22crossSectionScale%22:263.74955563693914%2C%22projectionScale%22:65536%2C%22layers%22:%5B%7B%22type%22:%22image%22%2C%22source%22:%7B%22url%22:%22deepzoom://https://data-proxy.ebrains.eu/api/v1/buckets/localizoom/14122_mPPC_BDA_s186.tif/14122_mPPC_BDA_s186.dzi%22%2C%22transform%22:%7B%22outputDimensions%22:%7B%22x%22:%5B1e-9%2C%22m%22%5D%2C%22y%22:%5B1e-9%2C%22m%22%5D%2C%22c%5E%22:%5B1%2C%22%22%5D%7D%2C%22inputDimensions%22:%7B%22x%22:%5B3.25e-7%2C%22m%22%5D%2C%22y%22:%5B3.25e-7%2C%22m%22%5D%2C%22c%5E%22:%5B1%2C%22%22%5D%7D%7D%7D%2C%22tab%22:%22rendering%22%2C%22shader%22:%22void%20main%28%29%7BemitRGB%28vec3%28toNormalized%28getDataValue%280%29%29%2CtoNormalized%28getDataValue%281%29%29%2CtoNormalized%28getDataValue%282%29%29%29%29%3B%7D%22%2C%22channelDimensions%22:%7B%22c%5E%22:%5B1%2C%22%22%5D%7D%2C%22name%22:%2214122_mPPC_BDA_s186.dzi%22%7D%5D%2C%22selectedLayer%22:%7B%22layer%22:%2214122_mPPC_BDA_s186.dzi%22%7D%2C%22layout%22:%22xy%22%7D"
target="_blank">Open viewer.</a> (Use <kbd>Ctrl</kbd>+<kbd>MouseWheel</kbd> to zoom out)

This image is part of: Olsen et al., 2020. Anterogradely labeled axonal projections from the posterior parietal cortex in rat [Data set]. EBRAINS. <https://doi.org/10.25493/FKM4-ZCC>

# Supported data sources

Neuroglancer itself is purely a client-side program, but it depends on data being accessible via HTTP in a suitable format. It is designed to easily support many different data sources, and there is existing support for the following data APIs/formats:
Expand All @@ -40,6 +45,7 @@ Neuroglancer itself is purely a client-side program, but it depends on data bein
- DVID <https://github.com/janelia-flyem/dvid>
- Render <https://github.com/saalfeldlab/render>
- Single NIfTI files <https://www.nitrc.org/projects/nifti>
- [Deep Zoom images](src/neuroglancer/datasource/deepzoom)

# Supported browsers

Expand Down
7 changes: 7 additions & 0 deletions config/bundle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ const DEFAULT_DATA_SOURCES = exports.DEFAULT_DATA_SOURCES = [
'neuroglancer/async_computation/decode_gzip',
],
},
{
source: 'neuroglancer/datasource/deepzoom',
asyncComputation: [
'neuroglancer/async_computation/decode_jpeg',
'neuroglancer/async_computation/decode_png',
],
},
{
source: 'neuroglancer/datasource/dvid',
registerCredentials: 'neuroglancer/datasource/dvid/register_credentials_provider',
Expand Down
19 changes: 16 additions & 3 deletions config/esbuild-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ async function main(argv) {
let minify = true;
let python = false;
let moduleBuild = false;
let outDir = undefined;
let outDir = argv.output;
let id = argv.config;
const pythonOutDir = path.resolve(__dirname, '..', 'python', 'neuroglancer', 'static');
const pythonOutDir = argv.output !== undefined ?
argv.output :
path.resolve(__dirname, '..', 'python', 'neuroglancer', 'static');

switch (id) {
case 'min':
Expand Down Expand Up @@ -117,8 +119,9 @@ async function main(argv) {
define: argv.define,
inject: argv.inject,
googleTagManager: argv.googleTagManager,
analyze: argv.analyze,
});
if (moduleBuild) {
if (moduleBuild && argv.output === undefined) {
try {
if ((await fs.promises.lstat(builder.outDir)).isDirectory()) {
await fs.promises.rmdir(builder.outDir, {recursive: true});
Expand Down Expand Up @@ -151,6 +154,11 @@ if (require.main === module) {
choices: ['min', 'dev', 'python-min', 'python-dev', 'module'],
default: 'min',
},
analyze: {
type: 'boolean',
default: false,
description: 'Print bundle analysis.',
},
typecheck: {
type: 'boolean',
default: true,
Expand Down Expand Up @@ -199,6 +207,11 @@ if (require.main === module) {
description: 'Additional JSON/JavaScript config file to load.',
configParser: x => mungeConfig(require(x)),
},
output: {
type: 'string',
nargs: 1,
description: 'Output directory.',
},
['google-tag-manager']: {
group: 'Customization',
type: 'string',
Expand Down
8 changes: 7 additions & 1 deletion config/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Builder {
inject = [],
minify = true,
googleTagManager = undefined,
analyze = false,
} = options;
this.outDir = outDir;
this.cacheId = id;
Expand All @@ -87,6 +88,7 @@ class Builder {
this.define = define;
this.inject = inject;
this.googleTagManager = googleTagManager;
this.analyze = analyze;
}

// Deletes .js/.css/.html files from `this.outDir`. Can safely be used on
Expand Down Expand Up @@ -190,12 +192,16 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
path.resolve(this.srcDir, 'neuroglancer/datasource/boss/bossauth.html'),
path.resolve(this.outDir, 'bossauth.html'));
}
await esbuild.build({
const result = await esbuild.build({
...this.getBaseEsbuildConfig(),
entryPoints: [this.getMainEntrypoint(), ...this.getWorkerEntrypoints()],
bundle: true,
sourcemap: true,
metafile: true,
});
if (this.analyze) {
console.log(await esbuild.analyzeMetafile(result.metafile));
}
}

async buildModule() {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build-system]
requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm", "oldest-supported-numpy"]
requires = ["setuptools>=64", "wheel", "setuptools_scm", "oldest-supported-numpy"]
Loading

0 comments on commit c7cf26b

Please sign in to comment.