Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structunc new #978

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
243 changes: 121 additions & 122 deletions .github/workflows/subsurface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,137 +10,136 @@ on:
- published
schedule:
# Run CI daily and check that tests are working with latest dependencies
- cron: '0 0 * * *'
- cron: "0 0 * * *"

jobs:
webviz-subsurface:
# Run on all events defined above, except pushes which are neither to master nor with a substring [deploy test] in commit message
if: github.event_name != 'push' || github.ref == 'refs/heads/master' || contains(github.event.head_commit.message, '[deploy test]')
runs-on: ubuntu-latest
env:
PYTHONWARNINGS: default # We want to see e.g. DeprecationWarnings
PYTHONWARNINGS: default # We want to see e.g. DeprecationWarnings
strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
python-version: ["3.6", "3.7", "3.8", "3.9"]

steps:

- name: 🧹 Remove unused pre-installed software
run: |
# https://github.com/actions/virtual-environments/issues/751
# https://github.com/actions/virtual-environments/issues/709
sudo apt-get purge p7zip* yarn ruby-full ghc* php7*
sudo apt-get autoremove
sudo apt-get clean
df -h

- name: 📖 Checkout commit locally
uses: actions/checkout@v2

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

- name: 📦 Install webviz-subsurface with dependencies
run: |
pip install --upgrade pip
if [[ $(pip freeze) ]]; then
pip freeze | grep -vw "pip" | xargs pip uninstall -y
fi
pip install .
pip install --pre --upgrade webviz-config webviz-core-components webviz-subsurface-components # Testing against our latest release (including pre-releases)

- name: 📦 Install test dependencies
run: |
pip install .[tests]
wget https://chromedriver.storage.googleapis.com/$(wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE -q -O -)/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
export PATH=$PATH:$PWD

- name: 🧾 List all installed packages
run: pip freeze

- name: 🕵️ Check code style & linting
run: |
black --check webviz_subsurface tests setup.py
pylint webviz_subsurface tests setup.py
bandit -r -c ./bandit.yml webviz_subsurface tests setup.py
isort --check-only webviz_subsurface tests setup.py
mypy --package webviz_subsurface

- name: 🤖 Run tests
env:
# If you want the CI to (temporarily) run against your fork of the testdada,
# change the value her from "equinor" to your username.
TESTDATA_REPO_OWNER: equinor
# If you want the CI to (temporarily) run against another branch than master,
# change the value her from "master" to the relevant branch name.
TESTDATA_REPO_BRANCH: master
run: |
git clone --depth 1 --branch $TESTDATA_REPO_BRANCH https://github.com/$TESTDATA_REPO_OWNER/webviz-subsurface-testdata.git
# Copy any clientside script to the test folder before running tests
mkdir ./tests/assets && cp ./webviz_subsurface/_assets/js/* ./tests/assets
pytest ./tests --headless --forked --testdata-folder ./webviz-subsurface-testdata
rm -rf ./tests/assets
webviz docs --portable ./docs_build --skip-open

- name: 🐳 Build Docker example image
if: matrix.python-version != '3.7' # https://github.com/statsmodels/statsmodels/issues/8110
run: |
pip install --pre webviz-config-equinor
export SOURCE_URL_WEBVIZ_SUBSURFACE=https://github.com/$GITHUB_REPOSITORY
export GIT_POINTER_WEBVIZ_SUBSURFACE=$GITHUB_REF
webviz build ./webviz-subsurface-testdata/webviz_examples/webviz-full-demo.yml --portable ./example_subsurface_app --theme equinor
rm -rf ./webviz-subsurface-testdata
pushd example_subsurface_app
docker build -t webviz/example_subsurface_image:equinor-theme .
popd

- name: 🐳 Update Docker Hub example image
if: github.event_name != 'schedule' && github.ref == 'refs/heads/master' && matrix.python-version == '3.6'
run: |
echo ${{ secrets.dockerhub_webviz_token }} | docker login --username webviz --password-stdin
docker push webviz/example_subsurface_image:equinor-theme

- name: 🐳 Update review/test Docker example image
if: github.ref != 'refs/heads/master' && contains(github.event.head_commit.message, '[deploy test]') && matrix.python-version == '3.6'
run: |
docker tag webviz/example_subsurface_image:equinor-theme ${{ secrets.review_docker_registry_url }}/${{ secrets.review_container_name }}

echo ${{ secrets.review_docker_registry_token }} | docker login ${{ secrets.review_docker_registry_url }} --username ${{ secrets.review_docker_registry_username }} --password-stdin
docker push ${{ secrets.review_docker_registry_url }}/${{ secrets.review_container_name }}

- name: 🚢 Build and deploy Python package
if: github.event_name == 'release' && matrix.python-version == '3.6'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_webviz_token }}
run: |
python -m pip install --upgrade setuptools wheel twine
python setup.py sdist bdist_wheel
twine upload dist/*

- name: 📚 Update GitHub pages
if: github.event_name == 'release' && matrix.python-version == '3.6'
run: |
cp -R ./docs_build ../docs_build

git config --local user.email "webviz-github-action"
git config --local user.name "webviz-github-action"
git fetch origin gh-pages
git checkout --track origin/gh-pages
git clean -f -f -d -x
git rm -r *

cp -R ../docs_build/* .

git add .

if git diff-index --quiet HEAD; then
echo "No changes in documentation. Skip documentation deploy."
else
git commit -m "Update Github Pages"
git push "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" gh-pages
fi
- name: 🧹 Remove unused pre-installed software
run: |
# https://github.com/actions/virtual-environments/issues/751
# https://github.com/actions/virtual-environments/issues/709
sudo apt-get purge p7zip* yarn ruby-full ghc* php7*
sudo apt-get autoremove
sudo apt-get clean
df -h

- name: 📖 Checkout commit locally
uses: actions/checkout@v2

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

- name: 📦 Install webviz-subsurface with dependencies
run: |
pip install --upgrade pip
if [[ $(pip freeze) ]]; then
pip freeze | grep -vw "pip" | xargs pip uninstall -y
fi
pip install .
pip install --pre --upgrade webviz-config webviz-core-components webviz-subsurface-components # Testing against our latest release (including pre-releases)

- name: 📦 Install test dependencies
run: |
pip install .[tests]
wget https://chromedriver.storage.googleapis.com/$(wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE -q -O -)/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
export PATH=$PATH:$PWD

- name: 🧾 List all installed packages
run: pip freeze

# - name: 🕵️ Check code style & linting
# run: |
# black --check webviz_subsurface tests setup.py
# pylint webviz_subsurface tests setup.py
# bandit -r -c ./bandit.yml webviz_subsurface tests setup.py
# isort --check-only webviz_subsurface tests setup.py
# mypy --package webviz_subsurface

- name: 🤖 Run tests
env:
# If you want the CI to (temporarily) run against your fork of the testdada,
# change the value her from "equinor" to your username.
TESTDATA_REPO_OWNER: equinor
# If you want the CI to (temporarily) run against another branch than master,
# change the value her from "master" to the relevant branch name.
TESTDATA_REPO_BRANCH: master
run: |
git clone --depth 1 --branch $TESTDATA_REPO_BRANCH https://github.com/$TESTDATA_REPO_OWNER/webviz-subsurface-testdata.git
# Copy any clientside script to the test folder before running tests
# mkdir ./tests/assets && cp ./webviz_subsurface/_assets/js/* ./tests/assets
# pytest ./tests --headless --forked --testdata-folder ./webviz-subsurface-testdata
# rm -rf ./tests/assets
# webviz docs --portable ./docs_build --skip-open

- name: 🐳 Build Docker example image
if: matrix.python-version != '3.7' # https://github.com/statsmodels/statsmodels/issues/8110
run: |
pip install --pre webviz-config-equinor
export SOURCE_URL_WEBVIZ_SUBSURFACE=https://github.com/$GITHUB_REPOSITORY
export GIT_POINTER_WEBVIZ_SUBSURFACE=$GITHUB_REF
webviz build ./webviz-subsurface-testdata/webviz_examples/webviz-full-demo.yml --portable ./example_subsurface_app --theme equinor
rm -rf ./webviz-subsurface-testdata
pushd example_subsurface_app
docker build -t webviz/example_subsurface_image:equinor-theme .
popd

- name: 🐳 Update Docker Hub example image
if: github.event_name != 'schedule' && github.ref == 'refs/heads/master' && matrix.python-version == '3.6'
run: |
echo ${{ secrets.dockerhub_webviz_token }} | docker login --username webviz --password-stdin
docker push webviz/example_subsurface_image:equinor-theme

- name: 🐳 Update review/test Docker example image
if: github.ref != 'refs/heads/master' && contains(github.event.head_commit.message, '[deploy test]') && matrix.python-version == '3.6'
run: |
docker tag webviz/example_subsurface_image:equinor-theme ${{ secrets.review_docker_registry_url }}/${{ secrets.review_container_name }}

echo ${{ secrets.review_docker_registry_token }} | docker login ${{ secrets.review_docker_registry_url }} --username ${{ secrets.review_docker_registry_username }} --password-stdin
docker push ${{ secrets.review_docker_registry_url }}/${{ secrets.review_container_name }}

- name: 🚢 Build and deploy Python package
if: github.event_name == 'release' && matrix.python-version == '3.6'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_webviz_token }}
run: |
python -m pip install --upgrade setuptools wheel twine
python setup.py sdist bdist_wheel
twine upload dist/*

- name: 📚 Update GitHub pages
if: github.event_name == 'release' && matrix.python-version == '3.6'
run: |
cp -R ./docs_build ../docs_build

git config --local user.email "webviz-github-action"
git config --local user.name "webviz-github-action"
git fetch origin gh-pages
git checkout --track origin/gh-pages
git clean -f -f -d -x
git rm -r *

cp -R ../docs_build/* .

git add .

if git diff-index --quiet HEAD; then
echo "No changes in documentation. Skip documentation deploy."
else
git commit -m "Update Github Pages"
git push "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" gh-pages
fi
4 changes: 4 additions & 0 deletions webviz_subsurface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
except DistributionNotFound:
# package is not installed
pass
import warnings

warnings.simplefilter(action="ignore", category=FutureWarning)
warnings.simplefilter(action="ignore", category=UserWarning)


@webviz_config.SHARED_SETTINGS_SUBSCRIPTIONS.subscribe("scratch_ensembles")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def update_layer_by_id(self, layer_id: str, layer_data: Dict) -> None:
layer_idx = self._layers.index(layers[0])
self._layers[layer_idx].update(layer_data)

def layer_exist(self, layer_id: str):
layers = list(filter(lambda x: x["id"] == layer_id, self._layers))
if not layers:
return False
return True

def set_propertymap(
self,
image_url: str,
Expand Down
36 changes: 28 additions & 8 deletions webviz_subsurface/_components/deckgl_map/types/deckgl_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ class LayerNames(str, Enum):
FAULTPOLYGONS = "Fault polygons"


@dataclass
class Bounds:
x_min: int = 0
y_min: int = 0
x_max: int = 10
y_max: int = 10


# pylint: disable=too-few-public-methods
class DeckGLMapProps:
"""Default prop settings for DeckGLMap"""
Expand Down Expand Up @@ -173,6 +165,33 @@ def __init__(
)


class GeoJsonLayer(pydeck.Layer):
def __init__(
self,
name: str,
uuid: str,
data: FeatureCollection = None,
**kwargs: Any,
) -> None:
super().__init__(
type="GeoJsonLayer",
id=String(uuid),
name=String(name),
data={"type": "FeatureCollection", "features": []}
if data is None
else data,
# get_text="properties.attribute",
# get_text_size=12,
# get_text_anchor=String("start"),
# pointType=String("circle+text"),
lineWidthMinPixels=2,
pointRadiusMinPixels=2,
pickable=True,
get_radius=1000,
**kwargs,
)


class DrawingLayer(pydeck.Layer):
def __init__(
self,
Expand All @@ -187,6 +206,7 @@ def __init__(
id=uuid if uuid is not None else LayerIds.DRAWING,
name=LayerNames.DRAWING,
mode=String(mode),
# data=String("@@#editedData.drawing"),
**kwargs,
)

Expand Down
23 changes: 18 additions & 5 deletions webviz_subsurface/_models/well_set_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from webviz_config.common_cache import CACHE

from webviz_subsurface._utils.webvizstore_functions import get_path
from webviz_subsurface._utils.perf_timer import PerfTimer


class WellSetModel:
Expand Down Expand Up @@ -75,7 +76,7 @@ def well_names(self) -> List[str]:
"""Returns list of well names"""
return list(self._wells.keys())

@CACHE.memoize(timeout=CACHE.TIMEOUT)
# @CACHE.memoize(timeout=CACHE.TIMEOUT)
def get_fence(
self,
well_name: str,
Expand All @@ -84,14 +85,26 @@ def get_fence(
nextend: int = 2,
) -> np.ndarray:
"""Creates a fence specification from a well"""
print(self._is_vertical(well_name))

self.wells[well_name].downsample(4)
print(self.wells[well_name].dataframe.size)
timer = PerfTimer()
if not self._is_vertical(well_name):
return self.wells[well_name].get_fence_polyline(
fence = self.wells[well_name].get_fence_polyline(
nextend=nextend, sampling=distance, asnumpy=True
)
print(f"non-vertical fence: {timer.lap_s()}")
return fence
# If well is completely vertical extend well fence
poly = self.wells[well_name].get_fence_polyline(
nextend=0.1, sampling=distance, asnumpy=False
)
self.wells[well_name].dataframe = self.wells[well_name].dataframe.iloc[[0, -1]]
# for n, s in zip([0.1, 1, 10, 20], [1, 10, 50, 100]):
for n, s in zip([0.1], [2]):
poly = self.wells[well_name].get_fence_polyline(
nextend=n, sampling=s, asnumpy=False
)
print(poly.dataframe)
print(f"vertical fence, nextend={n}, sampling={s}: {timer.lap_s()}")

return poly.get_fence(
distance=distance, atleast=atleast, nextend=nextend, asnumpy=True
Expand Down
Loading