From 295134dba96f75847469f6d41b4eafd7279e121d Mon Sep 17 00:00:00 2001
From: Simon Ward <2798086+wardsimon@users.noreply.github.com>
Date: Mon, 4 Oct 2021 16:07:30 +0200
Subject: [PATCH 1/5] Create binder scripts
---
.pre-commit-config.yaml | 9 +++++++--
binder/postBuild | 4 ++++
requirements-dev.txt | 8 ++++++++
3 files changed, 19 insertions(+), 2 deletions(-)
create mode 100644 binder/postBuild
create mode 100644 requirements-dev.txt
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 7d6b7786..321785c5 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -15,8 +15,13 @@ repos:
- id: check-toml
- id: pretty-format-json
- id: detect-private-key
-#- repo: local
-# hooks:
+- repo: local
+ hooks:
+ - id: export_dev_requirements
+ name: Export dev requirements
+ language: system
+ pass_filenames: false
+ entry: peodd -o requirements-dev.txt
# - id: export-requirements
# name: Export requeriments.txt
# language: system
diff --git a/binder/postBuild b/binder/postBuild
new file mode 100644
index 00000000..315ca3cb
--- /dev/null
+++ b/binder/postBuild
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+pip install -r requirements-dev.txt
+jupyter labextension install jupyterlab_3dmol
\ No newline at end of file
diff --git a/requirements-dev.txt b/requirements-dev.txt
new file mode 100644
index 00000000..6fedc5e1
--- /dev/null
+++ b/requirements-dev.txt
@@ -0,0 +1,8 @@
+pytest>=5.2
+toml>=0.10
+requests>=2.24
+hvplot>=0.7.0
+jupyter>=1.0.0
+ipympl>=0.8.0
+matplotlib>=3.4
+py3Dmol>=1.7.0
From 681551b12ebb5fdd64c7519a4d01b865c408f3c2 Mon Sep 17 00:00:00 2001
From: Simon Ward <2798086+wardsimon@users.noreply.github.com>
Date: Mon, 4 Oct 2021 16:25:52 +0200
Subject: [PATCH 2/5] Remove unnecessary jupyter
---
binder/postBuild | 3 +--
pyproject.toml | 1 -
requirements-dev.txt | 1 -
3 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/binder/postBuild b/binder/postBuild
index 315ca3cb..a7b14ce0 100644
--- a/binder/postBuild
+++ b/binder/postBuild
@@ -1,4 +1,3 @@
#!/bin/bash
-pip install -r requirements-dev.txt
-jupyter labextension install jupyterlab_3dmol
\ No newline at end of file
+pip install -r requirements-dev.txt
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 159ea884..b0e8cf53 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -42,7 +42,6 @@ pytest = "^5.2"
toml = "^0.10"
requests = '^2.24'
hvplot = "^0.7.0"
-jupyter = "^1.0.0"
ipympl = "^0.8.0"
matplotlib = "^3.4"
py3Dmol = "^1.7.0"
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 6fedc5e1..57b55ece 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -2,7 +2,6 @@ pytest>=5.2
toml>=0.10
requests>=2.24
hvplot>=0.7.0
-jupyter>=1.0.0
ipympl>=0.8.0
matplotlib>=3.4
py3Dmol>=1.7.0
From dc4a35e0e54aca5b5cdd0d9a122e6842ec61d3b5 Mon Sep 17 00:00:00 2001
From: Simon Ward <2798086+wardsimon@users.noreply.github.com>
Date: Tue, 5 Oct 2021 10:05:58 +0200
Subject: [PATCH 3/5] Explicit external libs
---
binder/postBuild | 1 +
1 file changed, 1 insertion(+)
diff --git a/binder/postBuild b/binder/postBuild
index a7b14ce0..1b275d62 100644
--- a/binder/postBuild
+++ b/binder/postBuild
@@ -1,3 +1,4 @@
#!/bin/bash
+pip install --extra-index-url https://easyscience.github.io/pypi -r requirements.txt
pip install -r requirements-dev.txt
\ No newline at end of file
From f589271cb5749c96c8d270f9af773a5b53c5a79e Mon Sep 17 00:00:00 2001
From: Simon Ward <2798086+wardsimon@users.noreply.github.com>
Date: Tue, 5 Oct 2021 10:20:54 +0200
Subject: [PATCH 4/5] Add correct path when using binder
---
examples/Fitting.ipynb | 8 +++++++-
examples/Simulation.ipynb | 9 +++++++--
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/examples/Fitting.ipynb b/examples/Fitting.ipynb
index 9fb39a33..b77042cd 100644
--- a/examples/Fitting.ipynb
+++ b/examples/Fitting.ipynb
@@ -40,6 +40,12 @@
"from easyCore import np\n",
"from easyCore.Fitting.Fitting import Fitter\n",
"\n",
+ "try:\n",
+ " from easyDiffractionLib import Phase\n",
+ "except ImportError:\n",
+ " import sys, os\n",
+ " sys.path.append(os.path.abspath('..'))\n",
+ "\n",
"# esyScience, diffraction\n",
"from easyDiffractionLib import Phases\n",
"from easyDiffractionLib.sample import Sample as Job\n",
@@ -1072,4 +1078,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
-}
+}
\ No newline at end of file
diff --git a/examples/Simulation.ipynb b/examples/Simulation.ipynb
index 9b2eaa02..15f33aae 100644
--- a/examples/Simulation.ipynb
+++ b/examples/Simulation.ipynb
@@ -27,7 +27,12 @@
"source": [
"# esyScience, technique-independent\n",
"from easyCore import np\n",
- "from easyCore.Fitting.Fitting import Fitter\n",
+ "\n",
+ "try:\n",
+ " from easyDiffractionLib import Phase\n",
+ "except ImportError:\n",
+ " import sys, os\n",
+ " sys.path.append(os.path.abspath('..'))\n",
"\n",
"# esyScience, diffraction\n",
"from easyDiffractionLib import Site, Phase, Phases\n",
@@ -2525,4 +2530,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
-}
+}
\ No newline at end of file
From c87c1b68fd0902c2ed3bf62709a86bbaa9d48568 Mon Sep 17 00:00:00 2001
From: Simon Ward <2798086+wardsimon@users.noreply.github.com>
Date: Tue, 5 Oct 2021 10:44:00 +0200
Subject: [PATCH 5/5] Update readme [ci skip]
---
README.md | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 22086b5f..f4ee6029 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
-# [![Unit Tests][20]][21] ![Release][31] [![Downloads][70]][71] [![Lines of code][81]](<>) [![Total lines][80]](<>) [![Files][82]](<>) [![License][50]][51]
+# [![Unit Tests][20]][21] ![Release][31] [![Downloads][70]][71] [![Lines of code][81]](<>) [![Total lines][80]](<>) [![Files][82]](<>) [![License][50]][51] [](https://mybinder.org/v2/gh/easyScience/easyDiffractionLib/develop)
+
![]()
@@ -56,6 +57,10 @@ Currently **easyDiffractionLib** is in **alpha** and has not been released on **
```
* Select one of the ***.ipynb** files
+### Via Binder
+
+Examples can also be run on the online service [binder](https://mybinder.org/). [](https://mybinder.org/v2/gh/easyScience/easyDiffractionLib/develop) and navigate to the examples folder to run one of the notebooks or create your own.
+
## Test
The installation can be verified by running the test suite: