Skip to content
Snippets Groups Projects
Commit d5f22aa7 authored by alice grosch's avatar alice grosch
Browse files

Update license

parent de204653
Branches
Tags
No related merge requests found
[run]
omit = dicom_upload/tests/*
language: python
python:
- 3.7
- 3.6
- 3.5
sudo: false
dist: xenial
services:
- xvfb
addons:
apt_packages:
- pandoc
env:
matrix:
- GROUP=python
matrix:
include:
- python: 3.5
env: GROUP=js
include:
- python: 3.6
env: GROUP=docs
cache:
pip: true
directories:
- node_modules # NPM packages
- $HOME/.npm
before_install:
- pip install -U pip setuptools
- nvm install 8
- |
if [[ $GROUP == python ]]; then
pip install codecov
elif [[ $GROUP == js ]]; then
npm install -g codecov
fi
install:
- |
if [[ $GROUP == python ]]; then
pip install --upgrade ".[test]" -v
elif [[ $GROUP == js ]]; then
pip install --upgrade -e ".[test]" -v
elif [[ $GROUP == docs ]]; then
pip install --upgrade ".[test, examples, docs]" -v
fi
before_script:
# Set up a virtual screen for Firefox browser testing:
- |
if [[ $GROUP == js ]]; then
export CHROME_BIN=chromium-browser
fi
git config --global user.email travis@fake.com
git config --global user.name "Travis CI"
script:
- |
if [[ $GROUP == python ]]; then
EXIT_STATUS=0
pushd $(mktemp -d)
py.test -l --cov-report xml:$TRAVIS_BUILD_DIR/coverage.xml --cov=dicom_upload --pyargs dicom_upload || EXIT_STATUS=$?
popd
(exit $EXIT_STATUS)
elif [[ $GROUP == js ]]; then
npm test
elif [[ $GROUP == docs ]]; then
EXIT_STATUS=0
cd docs
make html || EXIT_STATUS=$?
make linkcheck || EXIT_STATUS=$?
cd ..
python -m pytest_check_links --links-ext=.md -o testpaths=. -o addopts= || EXIT_STATUS=$?
(exit $EXIT_STATUS)
fi
after_success:
- codecov
Copyright (c) 2019 Alice Grosch
Copyright (c) 2019 Juelich Supercomputing Centre (JSC)
All rights reserved.
Alice Grosch <a.grosch@fz-juelich.de>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
......
......@@ -4,7 +4,11 @@
[![codecov](https://codecov.io/gh/jsc/dicom-upload/branch/master/graph/badge.svg)](https://codecov.io/gh/jsc/dicom-upload)
Upload DICOM files with removed headers.
FileUpload Widget using the Jupyter Notebook Server RestAPI.
Uploads DICOM files with anonymized headers, i.d. the 0004 and
0010 tags are removed on JS side before the upload.
Can handle large files by uploading files in chunks.
## Installation
......
# Do not build feature branch with open Pull Requests
skip_branch_with_pr: true
# environment variables
environment:
nodejs_version: "8"
matrix:
- PYTHON: "C:\\Miniconda3-x64"
PYTHON_VERSION: "3.7"
PYTHON_MAJOR: 3
PYTHON_ARCH: "64"
- PYTHON: "C:\\Miniconda3"
PYTHON_VERSION: "3.4"
PYTHON_MAJOR: 3
PYTHON_ARCH: "32"
# build cache to preserve files/folders between builds
cache:
- '%AppData%/npm-cache'
- '%PYTHON%/pkgs'
- '%LOCALAPPDATA%\pip\Cache'
# scripts that run after cloning repository
install:
# Install node:
- ps: Install-Product node $env:nodejs_version
# Ensure python scripts are from right version:
- 'SET "PATH=%PYTHON%\Scripts;%PYTHON%;%PATH%"'
# Setup conda:
- 'conda list'
- 'conda update conda -y'
# If 32 bit, force conda to use it:
- 'IF %PYTHON_ARCH% EQU 32 SET CONDA_FORCE_32BIT=1'
- 'conda create -n test_env python=%PYTHON_VERSION% -y'
- 'activate test_env'
# Update install tools:
- 'conda install setuptools pip -y'
- 'python -m pip install --upgrade pip'
- 'python -m easy_install --upgrade setuptools'
# Install coverage utilities:
- 'pip install codecov'
# Install our package:
- 'pip install --upgrade ".[test]" -v'
build: off
# scripts to run before tests
before_test:
- git config --global user.email appveyor@fake.com
- git config --global user.name "AppVeyor CI"
- set "tmptestdir=%tmp%\dicom_upload-%RANDOM%"
- mkdir "%tmptestdir%"
- cd "%tmptestdir%"
# to run your custom scripts instead of automatic tests
test_script:
- 'py.test -l --cov-report xml:"%APPVEYOR_BUILD_FOLDER%\coverage.xml" --cov=dicom_upload --pyargs dicom_upload'
on_success:
- cd "%APPVEYOR_BUILD_FOLDER%"
- codecov -X gcov --file "%APPVEYOR_BUILD_FOLDER%\coverage.xml"
comment: off
# show coverage in CI status, but never consider it a failure
coverage:
status:
project:
default:
target: 0%
patch:
default:
target: 0%
ignore:
- "dicom_upload/tests"
.custom-widget {
background-color: blue;
}
#!/usr/bin/env python
# coding: utf-8
# Copyright (c) Alice Grosch.
# Copyright (c) Juelich Supercomputing Centre (JSC).
# Distributed under the terms of the Modified BSD License.
"""
TODO: Add module docstring
DICOM Upload Widget using the Jupyter Notebook Server RestAPI.
Uploads DICOM files with anonymized headers, i.e. the 0008 and
0010 tags are removed on the JS side before the upload.
Files that aren't in DICOM format are ignored.
Can handle large files by uploading files in chunks.
"""
from ipywidgets import ValueWidget
from ipywidgets import register, widget_serialization
......@@ -20,7 +26,17 @@ from ._frontend import module_name, module_version
class Uploader(DescriptionWidget, ValueWidget):
"""TODO: Add docstring here
"""Upload Widget.
Uploads DICOM files only via the Jupyter Notebook Server RestAPI,
all other files will be ignored.
DICOM files are anonymized by removing header tags starting with
0008 and 0010 on the JS side before uploading.
The widget is able to upload large files by uploading them in chunks.
The file contents will however not be directly available over the widget,
but will have to be read into the notebook separately.
"""
_model_name = Unicode('UploaderModel').tag(sync=True)
_model_module = Unicode(module_name).tag(sync=True)
......@@ -46,13 +62,17 @@ class Uploader(DescriptionWidget, ValueWidget):
# Variables set on the JavaScript side.
files = List().tag(sync=True)
responses = List([]).tag(sync=True)
responses = List().tag(sync=True)
finished = Bool(False).tag(sync=True)
hash = Unicode().tag(sync=True)
_upload = Bool(False).tag(sync=True)
def __init__(self, upload_url='http://localhost:8888/api/contents/', token='', *args, **kwargs):
"""Args:
upload_url (str): Jupyter notebook URL appended by api/contents/<path>/. Directories on <path> must already exist.
token (str): Jupyter notebook authentication token.
"""
super(Uploader, self).__init__(*args, **kwargs)
self.upload_url = upload_url
self.token = token
......@@ -61,6 +81,6 @@ class Uploader(DescriptionWidget, ValueWidget):
def _default_description(self):
return 'Upload'
# Calls javascript function to upload.
def upload(self):
"""Uploads file(s) via the JS fetch API."""
self._upload = True
\ No newline at end of file
// Copyright (c) Alice Grosch
// Copyright (c) Juelich Supercomputing Centre (JSC)
// Distributed under the terms of the Modified BSD License.
import {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment