Skip to content

Commit

Permalink
Merge dd2f2f1 into fce962d
Browse files Browse the repository at this point in the history
  • Loading branch information
H0R5E committed Jul 14, 2022
2 parents fce962d + dd2f2f1 commit f827e32
Show file tree
Hide file tree
Showing 16 changed files with 270 additions and 101 deletions.
9 changes: 3 additions & 6 deletions .bandit
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

# (optional) list included test IDs here, eg '[B101, B406]':
# tests:

# (optional) list skipped test IDs here, eg '[B101, B406]':
skips: ['B101']
[bandit]
exclude: ./examples,./tests
skips: B101
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [3.1.0] - 2022-07-14

### Changed

- Changed the way that the non-code data is discovered. It now looks for
the dtocean-data conda package or the installer retrieved from the
https://github.com/DTOcean/dtocean-data repository.

### Removed

- The paths to the non-code data can no longer be modified in the user
configuration.

## [3.0.0] - 2021-10-12

### Added
Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ Distribution](https://www.anaconda.com/distribution/) (Python 2.7)

These installation instructions are for WINDOWS ONLY.

### Data Package (Required for ALL installation Methods)

The latest version of the hydrodynamic data package
(`dtocean-hydrodynamic-data-*.exe`) must be installed. This can be downloaded
from the [Releases](https://github.com/DTOcean/dtocean-hydrodynamics/releases/tag/v2.0.0)
page.

Once downloaded execute the file to install. If upgrading from version 1,
uninstall the old version first from the Windows start menu program folder,
or using the control panel. For version 2 and beyond, the uninstaller will
automatically remove the older version.

### Conda Package

To install:
Expand Down Expand Up @@ -112,6 +100,20 @@ To deactivate the conda environment:
$ conda deactivate
```

### Data Package

When installing from source, the DTOcean data package must also be installed.
This can either be installed using conda:

```
$ conda activate _dtocean_hydro
$ conda install dtocean-data
```

Or it can be downloaded from the [dtocean-data](https://github.com/DTOcean/dtocean-data)
repository, in the "Assets" section of the [latest release](
https://github.com/DTOcean/dtocean-data/releases/latest).

### Tests

A test suite is provided with the source code that uses [pytest](
Expand All @@ -127,13 +129,13 @@ $ conda activate _dtocean_hydro
Install pytest to the environment (one time only):

```
$ conda install -y pytest
$ conda install -y mock pytest pytest-mock
```

Run the tests:

```
$ py.test tests
$ pytest tests
```

### Uninstall
Expand Down
7 changes: 3 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#---------------------------------#

# version format
version: 3.0.0.build{build}
version: 3.1.0.build{build}

image:
- Visual Studio 2015
Expand All @@ -29,20 +29,19 @@ init:
- "ECHO %PYTHON_VERSION% %MINICONDA%"

install:
- ps: Start-FileDownload 'https://github.com/DTOcean/dtocean-hydrodynamics/releases/download/v2.0.0/dtocean-hydrodynamic-data-2.0.exe' 'dtocean-hydrodynamic-data-2.0.exe'
- dtocean-hydrodynamic-data-2.0.exe /verysilent
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%"
- conda config --set always_yes yes --set changeps1 no
- conda update --quiet conda
- conda info --all
- conda create -n _dtocean_hydro python=%PYTHON_VERSION% pip
- activate _dtocean_hydro
- copy .condarc %CONDA_PREFIX%
- conda install polite=0.10.0
- conda install "polite>=0.10.3"
- conda install -y numpy=1.11.3=py27hfef472a_4 libpython
- python setup.py bootstrap
- conda install --file requirements-conda-dev.txt
- pip install -e .
- conda install dtocean-data
- conda install mock pytest pytest-cov=2.5.1 pytest-mock

build: off
Expand Down
68 changes: 25 additions & 43 deletions dtocean_hydro/configure.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Copyright (C) 2016 Mathew Topper
# Copyright (C) 2016-2022 Mathew Topper
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -15,63 +15,45 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# Standard Library
import os
import logging

# Helpers for configuration files
from polite.paths import (ObjDirectory,
SiteDataDirectory,
UserDataDirectory,
DirectoryMap)
from polite.paths import (EtcDirectory,
SiteDataDirectory)
from polite.configuration import ReadINI

# Start logging
module_logger = logging.getLogger(__name__)


def get_install_paths():

"""Pick the necessary paths to configure the external files for the wave
and tidal packages."""

source_dir = ObjDirectory(__name__, "config")
user_data = UserDataDirectory("dtocean_hydro", "DTOcean", "config")
user_data_map = DirectoryMap(user_data, source_dir)

install_src_name = "install.ini"

# Check for bundled indicator file
if source_dir.isfile(".bundled"):
install_dst_name = "install_bundled.ini"
else:
install_dst_name = "install.ini"

log_msg = ("Install configuration file name set to "
"'{}'").format(install_dst_name)
module_logger.debug(log_msg)

user_data_map.safe_copy_file(install_src_name,
"{}.txt".format(install_dst_name))
user_ini_reader = ReadINI(user_data_map, install_dst_name)
# Look in the etc directory
etc_data = EtcDirectory("dtocean-data")
etc_ini_reader = ReadINI(etc_data, "install.ini")

# Get the root path from the site data path.
site_data = SiteDataDirectory("DTOcean Hydrodynamics", "DTOcean")
site_ini_reader = ReadINI(site_data, install_dst_name)
# Get the root path from the possible site data paths
site_data = SiteDataDirectory("DTOcean Data", "DTOcean")
site_ini_reader = ReadINI(site_data, "install.ini")
print site_data

if user_ini_reader.config_exists():
config = user_ini_reader.get_config()
if etc_ini_reader.config_exists():
config = etc_ini_reader.get_config()
elif site_ini_reader.config_exists():
config = site_ini_reader.get_config()
else:
errStr = ("No suitable configuration file found at paths "
"{} or {}").format(site_ini_reader.get_config_path(),
user_ini_reader.get_config_path())
"{} or {}").format(etc_ini_reader.get_config_path(),
site_ini_reader.get_config_path())
raise RuntimeError(errStr)

path_dict = {"bin" : config["dtocean_wec"]["bin_path"],
"wec_include" : config["dtocean_wec"]["include_path"],
"tidal_include" : config["dtocean_tidal"]["include_path"]
}

return path_dict


prefix = config["global"]["prefix"]
bin_path = os.path.join(prefix, config["global"]["bin_path"])
wec_share_path = os.path.join(prefix, config["dtocean_wec"]["share_path"])
tidal_share_path = os.path.join(prefix,
config["dtocean_tidal"]["share_path"])

return {"bin_path" : bin_path,
"wec_share_path" : wec_share_path,
"tidal_share_path" : tidal_share_path}
12 changes: 2 additions & 10 deletions dtocean_hydro/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ class WP2:
outputs are issued.
Attributes:
bin_dir (str): path name of the bin. The directory stores the
executable files for the BEM solver.
include_dir (str): path name of the include directory. The
directory stores the wave and tidal calculation and data
tidal_include (str): path name of the tida directory, where the
wake database is located.
wave_include (str): path name of the wave directory, where the BEM
solver results are located.
iInput (WP2input class): copy of the input argument.
iArray (Array_pkg class): contains the array related features as
lease area, active area, and generates the spatial arrangement
Expand All @@ -114,7 +106,6 @@ class WP2:
def __init__(self, WP2input,
Cfit=None,
Kfit=None,
pickup=False,
debug=False,
search_class=None,
optim_method=1):
Expand Down Expand Up @@ -224,7 +215,8 @@ def __init__(self, WP2input,
if WP2input.M_data.tidal_data_folder is None:
# Get path to data dirs through configuration
path_dict = get_install_paths()
self.cfd_data = read_database(path_dict["tidal_include"])
self.cfd_data = read_database(
path_dict["tidal_share_path"])
else:
self.cfd_data = read_database(
WP2input.M_data.tidal_data_folder)
Expand Down
4 changes: 2 additions & 2 deletions dtocean_wec/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def __init__(self):
# Get path to data dirs through configuration
path_dict = get_install_paths()

self.bin_path = path_dict["bin"]
self.wec_include_path = path_dict["wec_include"]
self.bin_path = path_dict["bin_path"]
self.wec_share_path = path_dict["wec_share_path"]

return

Expand Down
2 changes: 1 addition & 1 deletion dtocean_wec/pfit_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, parent=None):
self.trigger_results.connect(parent.task_end_pfit)
self.trigger_save.connect(parent.set_pfit_data)

self.db_folder = os.path.join(parent.wec_include_path, "wec_db")
self.db_folder = os.path.join(parent.wec_share_path, "wec_db")

self.__yaw = 0.0
self.__spectrum = "Jonswap"
Expand Down
2 changes: 1 addition & 1 deletion dtocean_wec/tab1.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, parent=None):
self.setupUi(self)

self.btn_load_data_t1.clicked.connect(self.load_data)
self._wec_db_folder = os.path.join(parent.wec_include_path, "wec_db")
self._wec_db_folder = os.path.join(parent.wec_share_path, "wec_db")
self.trigger_results.connect(parent.set_wec_db_results)
self.trigger_save.connect(parent.task_save_hydrodynamic)
self.trigger_save_prj.connect(parent.save_project)
Expand Down
2 changes: 1 addition & 1 deletion dtocean_wec/tab2.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, parent=None):
self.trigger_save.connect(parent.task_save_hydrodynamic)
self.trigger_reset_forms.connect(parent.task_reset_forms)
self.trigger_mesh_view.connect(parent.task_show_mesh)
self.db_folder = os.path.join(parent.wec_include_path, "wec_db")
self.db_folder = os.path.join(parent.wec_share_path, "wec_db")
self.bin_folder = parent.bin_path

self._raw = "raw_data"
Expand Down
2 changes: 1 addition & 1 deletion dtocean_wec/tab3.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, parent=None):
self.trigger_save.connect(parent.task_save_hydrodynamic)
self.trigger_reset_forms.connect(parent.task_reset_forms)

self.db_folder = os.path.join(parent.wec_include_path, "wec_db")
self.db_folder = os.path.join(parent.wec_share_path, "wec_db")
self.bin_folder = parent.bin_path

self.trigger_mesh_view.connect(parent.task_show_mesh)
Expand Down
2 changes: 1 addition & 1 deletion dtocean_wec/tab4.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, parent=None):

self.trigger_mesh_view.connect(parent.task_show_mesh)

self.db_folder = os.path.join(parent.wec_include_path, "wec_db")
self.db_folder = os.path.join(parent.wec_share_path, "wec_db")
self.bin_folder = parent.bin_path
self._raw = "raw_data"
self._prj = parent._data["prj_folder"]
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,12 @@ def get_appveyor_version():
packages=find_packages(),
install_requires=['cma',
'descartes',
# 'dtocean-data',
'h5py',
'matplotlib<2',
'numpy',
'pandas',
'polite>=0.9',
'polite>=0.10.3,<1',
'pyopengl',
# 'PyQt4',
'scikit-learn',
Expand Down
Loading

0 comments on commit f827e32

Please sign in to comment.