From e4a03aa50051b6cce871ea730fda6f9deaaa0115 Mon Sep 17 00:00:00 2001 From: Mostafa Farrag Date: Sun, 29 Dec 2024 16:14:34 +0100 Subject: [PATCH] Dev/update dependencies (#3) * remove un-needed files * update * update * update * add ci workflow * clean * add pytest * add import test * add release workflows * move to src * replace the setup.py by pyproject.toml * add test dependencies * clean * add history --- .azure-pipelines/azure-pipelines-linux.yml | 33 -------- .ci_support/README | 1 - .ci_support/linux_.yaml | 14 ---- .circleci/config.yml | 24 ------ .github/workflows/automerge.yml | 18 ----- .github/workflows/conda-deployment.yml | 41 ++++++++++ .github/workflows/github-release.yml | 36 +++++++++ .github/workflows/pypi-deployment.yml | 29 +++++++ .github/workflows/pypi-release.yml | 40 ++++++++++ .../snyk-infrastructure-analysis.yml | 42 ---------- .github/workflows/webservices.yml | 12 --- .scripts/build_steps.sh | 39 ---------- .scripts/run_docker_build.sh | 77 ------------------- .travis.yml | 47 ----------- HISTORY.rst | 11 +++ Oasis/requirement.txt | 3 - azure-pipelines.yml | 6 -- conda-forge.yml | 12 --- conda-forge/Oasis/LICENSE.txt | 21 ----- conda-forge/Oasis/meta.yaml | 44 ----------- conda/bld.bat | 2 - conda/build.sh | 1 - conda/meta.yaml | 45 ----------- environment.yml | 8 +- pyproject.toml | 51 ++++++++++++ recipe/meta - Copy.yaml | 52 ------------- recipe/meta.yaml | 52 ------------- requirement.txt | 4 - setup.py | 33 -------- {Oasis => src/Oasis}/__init__.py | 40 +--------- {Oasis => src/Oasis}/constraint.py | 0 {Oasis => src/Oasis}/gradient.py | 0 .../Oasis}/harmonysearch/__init__.py | 0 {Oasis => src/Oasis}/harmonysearch/hs.py | 0 {Oasis => src/Oasis}/harmonysearch/hsapi.py | 9 +-- {Oasis => src/Oasis}/history.py | 20 ++--- {Oasis => src/Oasis}/objective.py | 0 {Oasis => src/Oasis}/optimization.py | 0 {Oasis => src/Oasis}/optimizer.py | 4 +- {Oasis => src/Oasis}/parameter.py | 0 {Oasis => src/Oasis}/variable.py | 0 tests/test.py | 17 ---- tests/test_import.py | 4 + 43 files changed, 230 insertions(+), 662 deletions(-) delete mode 100755 .azure-pipelines/azure-pipelines-linux.yml delete mode 100644 .ci_support/README delete mode 100644 .ci_support/linux_.yaml delete mode 100644 .circleci/config.yml delete mode 100644 .github/workflows/automerge.yml create mode 100644 .github/workflows/conda-deployment.yml create mode 100644 .github/workflows/github-release.yml create mode 100644 .github/workflows/pypi-deployment.yml create mode 100644 .github/workflows/pypi-release.yml delete mode 100644 .github/workflows/snyk-infrastructure-analysis.yml delete mode 100644 .github/workflows/webservices.yml delete mode 100755 .scripts/build_steps.sh delete mode 100755 .scripts/run_docker_build.sh delete mode 100644 .travis.yml create mode 100644 HISTORY.rst delete mode 100644 Oasis/requirement.txt delete mode 100644 azure-pipelines.yml delete mode 100644 conda-forge.yml delete mode 100644 conda-forge/Oasis/LICENSE.txt delete mode 100644 conda-forge/Oasis/meta.yaml delete mode 100644 conda/bld.bat delete mode 100644 conda/build.sh delete mode 100644 conda/meta.yaml create mode 100644 pyproject.toml delete mode 100644 recipe/meta - Copy.yaml delete mode 100644 recipe/meta.yaml delete mode 100644 requirement.txt delete mode 100644 setup.py rename {Oasis => src/Oasis}/__init__.py (54%) rename {Oasis => src/Oasis}/constraint.py (100%) rename {Oasis => src/Oasis}/gradient.py (100%) rename {Oasis => src/Oasis}/harmonysearch/__init__.py (100%) rename {Oasis => src/Oasis}/harmonysearch/hs.py (100%) rename {Oasis => src/Oasis}/harmonysearch/hsapi.py (99%) rename {Oasis => src/Oasis}/history.py (91%) rename {Oasis => src/Oasis}/objective.py (100%) rename {Oasis => src/Oasis}/optimization.py (100%) rename {Oasis => src/Oasis}/optimizer.py (98%) rename {Oasis => src/Oasis}/parameter.py (100%) rename {Oasis => src/Oasis}/variable.py (100%) delete mode 100644 tests/test.py create mode 100644 tests/test_import.py diff --git a/.azure-pipelines/azure-pipelines-linux.yml b/.azure-pipelines/azure-pipelines-linux.yml deleted file mode 100755 index 7d71007..0000000 --- a/.azure-pipelines/azure-pipelines-linux.yml +++ /dev/null @@ -1,33 +0,0 @@ -# This file was generated automatically from conda-smithy. To update this configuration, -# update the conda-forge.yml and/or the recipe/meta.yaml. -# -*- mode: yaml -*- - -jobs: -- job: linux - pool: - vmImage: ubuntu-16.04 - strategy: - matrix: - linux_: - CONFIG: linux_ - UPLOAD_PACKAGES: 'True' - DOCKER_IMAGE: condaforge/linux-anvil-comp7 - maxParallel: 8 - timeoutInMinutes: 360 - - steps: - # configure qemu binfmt-misc running. This allows us to run docker containers - # embedded qemu-static - - script: | - docker run --rm --privileged multiarch/qemu-user-static:register --reset --credential yes - ls /proc/sys/fs/binfmt_misc/ - condition: not(startsWith(variables['CONFIG'], 'linux_64')) - displayName: Configure binfmt_misc - - - script: | - export CI=azure - export GIT_BRANCH=$BUILD_SOURCEBRANCHNAME - .scripts/run_docker_build.sh - displayName: Run docker build - env: - BINSTAR_TOKEN: $(BINSTAR_TOKEN) \ No newline at end of file diff --git a/.ci_support/README b/.ci_support/README deleted file mode 100644 index e4e2dce..0000000 --- a/.ci_support/README +++ /dev/null @@ -1 +0,0 @@ -This file is automatically generated by conda-smithy. To change any matrix elements, you should change conda-smithy's input conda_build_config.yaml and re-render the recipe, rather than editing these files directly. \ No newline at end of file diff --git a/.ci_support/linux_.yaml b/.ci_support/linux_.yaml deleted file mode 100644 index 43ef88d..0000000 --- a/.ci_support/linux_.yaml +++ /dev/null @@ -1,14 +0,0 @@ -channel_sources: -- conda-forge,defaults -channel_targets: -- conda-forge main -docker_image: -- condaforge/linux-anvil-comp7 -numpy: -- '1.14' -pin_run_as_build: - python: - min_pin: x.x - max_pin: x.x -python: -- 3.6.* *_cpython diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6ad461b..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,24 +0,0 @@ -# This file was generated automatically from conda-smithy. To update this configuration, -# update the conda-forge.yml and/or the recipe/meta.yaml. -# -*- mode: yaml -*- - -version: 2 - -jobs: - build: - working_directory: ~/test - machine: true - steps: - - run: - # The Circle-CI build should not be active, but if this is not true for some reason, do a fast finish. - command: exit 0 - -workflows: - version: 2 - build_and_test: - jobs: - - build: - filters: - branches: - ignore: - - /.*/ diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml deleted file mode 100644 index e8e5902..0000000 --- a/.github/workflows/automerge.yml +++ /dev/null @@ -1,18 +0,0 @@ -on: - status: {} - check_suite: - types: - - completed - -jobs: - automerge-action: - runs-on: ubuntu-latest - name: automerge - steps: - - name: checkout - uses: actions/checkout@v2 - - name: automerge-action - id: automerge-action - uses: conda-forge/automerge-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/conda-deployment.yml b/.github/workflows/conda-deployment.yml new file mode 100644 index 0000000..eb24035 --- /dev/null +++ b/.github/workflows/conda-deployment.yml @@ -0,0 +1,41 @@ +name: conda-deployment + +on: [push] + +jobs: + Main-package: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python-version: ["3.12"] + env: + OS: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 + with: + mamba-version: "*" + use-mamba: true + auto-update-conda: false + auto-activate-base: false + environment-file: environment.yml + activate-environment: test + python-version: ${{ matrix.python-version }} + channels: conda-forge + channel-priority: true + show-channel-urls: true + + - name: Install dev-dependencies + run: | + pip install .[test] + + - name: Run tests + shell: bash -el {0} + run: | + conda info + conda list + conda config --show-sources + conda config --show + pytest -sv diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml new file mode 100644 index 0000000..40038ab --- /dev/null +++ b/.github/workflows/github-release.yml @@ -0,0 +1,36 @@ +name: gitHub-release + +on: + workflow_dispatch: + push: + tags: + - '*' + +jobs: + create-release: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup GitHub CLI + run: | + type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ + && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ + && sudo apt update \ + && sudo apt install gh -y + + - name: Extract tag name + run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + + - name: Create GitHub Release + id: create_release + run: | + gh release create $TAG_NAME --title "$TAG_NAME" --notes-from-tag + env: + GH_TOKEN: ${{ secrets.CREATE_RELEASE }} diff --git a/.github/workflows/pypi-deployment.yml b/.github/workflows/pypi-deployment.yml new file mode 100644 index 0000000..6a9029f --- /dev/null +++ b/.github/workflows/pypi-deployment.yml @@ -0,0 +1,29 @@ +name: pypi-deployment + +on: [push] + +jobs: + Main-Package: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python-version: ["3.12"] + env: + OS: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + + - name: Install dependencies + run: | + pip install .[test] + + - name: Run Tests + run: | + pytest -vvv \ No newline at end of file diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml new file mode 100644 index 0000000..fc4640a --- /dev/null +++ b/.github/workflows/pypi-release.yml @@ -0,0 +1,40 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: pypi-release + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install poetry + run: | + pip install poetry + + - name: Configure Poetry + run: | + echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERS }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + poetry build + twine upload dist/* diff --git a/.github/workflows/snyk-infrastructure-analysis.yml b/.github/workflows/snyk-infrastructure-analysis.yml deleted file mode 100644 index c0f3320..0000000 --- a/.github/workflows/snyk-infrastructure-analysis.yml +++ /dev/null @@ -1,42 +0,0 @@ -# A sample workflow which checks out your Infrastructure as Code Configuration files, -# such as Kubernetes, Helm & Terraform and scans them for any security issues. -# The results are then uploaded to GitHub Security Code Scanning -# -# For more examples, including how to limit scans to only high-severity issues -# and fail PR checks, see https://github.com/snyk/actions/ - -name: Snyk Infrastructure as Code - -on: - push: - branches: [ master ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ master ] - schedule: - - cron: '25 20 * * 6' - -jobs: - snyk: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Run Snyk to check configuration files for security issues - # Snyk can be used to break the build when it detects security issues. - # In this case we want to upload the issues to GitHub Code Scanning - continue-on-error: true - uses: snyk/actions/iac@master - env: - # In order to use the Snyk Action you will need to have a Snyk API token. - # More details in https://github.com/snyk/actions#getting-your-snyk-token - # or you can signup for free at https://snyk.io/login - SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} - with: - # Add the path to the configuration file that you would like to test. - # For example `deployment.yaml` for a Kubernetes deployment manifest - # or `main.tf` for a Terraform configuration file - file: your-file-to-test.yaml - - name: Upload result to GitHub Code Scanning - uses: github/codeql-action/upload-sarif@v1 - with: - sarif_file: snyk.sarif diff --git a/.github/workflows/webservices.yml b/.github/workflows/webservices.yml deleted file mode 100644 index 78f51e6..0000000 --- a/.github/workflows/webservices.yml +++ /dev/null @@ -1,12 +0,0 @@ -on: repository_dispatch - -jobs: - webservices: - runs-on: ubuntu-latest - name: webservices - steps: - - name: webservices - id: webservices - uses: conda-forge/webservices-dispatch-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.scripts/build_steps.sh b/.scripts/build_steps.sh deleted file mode 100755 index bef68a0..0000000 --- a/.scripts/build_steps.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -# PLEASE NOTE: This script has been automatically generated by conda-smithy. Any changes here -# will be lost next time ``conda smithy rerender`` is run. If you would like to make permanent -# changes to this script, consider a proposal to conda-smithy so that other feedstocks can also -# benefit from the improvement. - -set -xeuo pipefail -export PYTHONUNBUFFERED=1 -export FEEDSTOCK_ROOT="${FEEDSTOCK_ROOT:-/home/conda/feedstock_root}" -export RECIPE_ROOT="${RECIPE_ROOT:-/home/conda/recipe_root}" -export CI_SUPPORT="${FEEDSTOCK_ROOT}/.ci_support" -export CONFIG_FILE="${CI_SUPPORT}/${CONFIG}.yaml" - -cat >~/.condarc </dev/null && pwd )" -PROVIDER_DIR="$(basename $THISDIR)" - -FEEDSTOCK_ROOT=$(cd "$(dirname "$0")/.."; pwd;) -RECIPE_ROOT="${FEEDSTOCK_ROOT}/recipe" - -docker info - -# In order for the conda-build process in the container to write to the mounted -# volumes, we need to run with the same id as the host machine, which is -# normally the owner of the mounted volumes, or at least has write permission -export HOST_USER_ID=$(id -u) -# Check if docker-machine is being used (normally on OSX) and get the uid from -# the VM -if hash docker-machine 2> /dev/null && docker-machine active > /dev/null; then - export HOST_USER_ID=$(docker-machine ssh $(docker-machine active) id -u) -fi - -ARTIFACTS="$FEEDSTOCK_ROOT/build_artifacts" - -if [ -z "$CONFIG" ]; then - set +x - FILES=`ls .ci_support/linux_*` - CONFIGS="" - for file in $FILES; do - CONFIGS="${CONFIGS}'${file:12:-5}' or "; - done - echo "Need to set CONFIG env variable. Value can be one of ${CONFIGS:0:-4}" - exit 1 -fi - -if [ -z "${DOCKER_IMAGE}" ]; then - SHYAML_INSTALLED="$(shyaml -h || echo NO)" - if [ "${SHYAML_INSTALLED}" == "NO" ]; then - echo "WARNING: DOCKER_IMAGE variable not set and shyaml not installed. Falling back to condaforge/linux-anvil-comp7" - DOCKER_IMAGE="condaforge/linux-anvil-comp7" - else - DOCKER_IMAGE="$(cat "${FEEDSTOCK_ROOT}/.ci_support/${CONFIG}.yaml" | shyaml get-value docker_image.0 condaforge/linux-anvil-comp7 )" - fi -fi - -mkdir -p "$ARTIFACTS" -DONE_CANARY="$ARTIFACTS/conda-forge-build-done-${CONFIG}" -rm -f "$DONE_CANARY" - -# Allow people to specify extra default arguments to `docker run` (e.g. `--rm`) -DOCKER_RUN_ARGS="${CONDA_FORGE_DOCKER_RUN_ARGS}" -if [ -z "${CI}" ]; then - DOCKER_RUN_ARGS="-it ${DOCKER_RUN_ARGS}" -fi - -export UPLOAD_PACKAGES="${UPLOAD_PACKAGES:-True}" -docker run ${DOCKER_RUN_ARGS} \ - -v "${RECIPE_ROOT}":/home/conda/recipe_root:rw,z \ - -v "${FEEDSTOCK_ROOT}":/home/conda/feedstock_root:rw,z \ - -e CONFIG \ - -e BINSTAR_TOKEN \ - -e HOST_USER_ID \ - -e UPLOAD_PACKAGES \ - -e GIT_BRANCH \ - -e UPLOAD_ON_BRANCH \ - -e CI \ - $DOCKER_IMAGE \ - bash \ - /home/conda/feedstock_root/${PROVIDER_DIR}/build_steps.sh - -# verify that the end of the script was reached -test -f "$DONE_CANARY" \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1e2a9ed..0000000 --- a/.travis.yml +++ /dev/null @@ -1,47 +0,0 @@ -language: python -# operating system, default is Xenial Linux -#os: windows # Windows 10.0.17134 N/A Build 17134 -python: - - "2.7" - - "3.5" - - "3.6" # current default Python on Travis CI - - "3.7" - - "3.8" -#env: DEPS= "ca-certificates=2020.4.5.1=hecc5488_0 certifi=2020.4.5.1=py37hc8dfbb8_0 pip python numpy" -before_install: - # Install the latest version of Miniconda - - wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh - - chmod +x miniconda.sh - - ./miniconda.sh -b - - export PATH=/home/travis/miniconda2/bin:$PATH - - conda update --yes conda - - conda info -a - -install: - # for python 3.4 as it does not exist in conda channels - # conda config --set restore_free_channel True - # Create a new environment - - conda create -q -n oasis python=${TRAVIS_PYTHON_VERSION} --yes - - source activate oasis - # Install various dependencies -# - conda install --yes $DEPS pip -# - while read requirement; do conda install --yes $requirement; done < requirement.txt - - conda install --yes --file requirement.txt - # You can add any CONDA channels you may need here. CONDA supports - # both the commands add and append. The only difference is that - # the add command places the channel at the front of the priority - # list, while append does the opposite. - - conda config --add channels conda-forge - - python -V - - python setup.py build_ext --inplace - - python setup.py install - - conda update --all --yes - - pip install --upgrade pytest pytest-cov -# - cd .. -# command to run tests -script: - - cd ./tests/ - - python test.py - -after_success: - - coveralls \ No newline at end of file diff --git a/HISTORY.rst b/HISTORY.rst new file mode 100644 index 0000000..bbf5882 --- /dev/null +++ b/HISTORY.rst @@ -0,0 +1,11 @@ +======= +History +======= + +1.0.3 (2024-12-24) +------------------ + +dev +*** +* replace the setup.py with pyproject.toml +* update to numpy > 2.0 and python > 3.12 diff --git a/Oasis/requirement.txt b/Oasis/requirement.txt deleted file mode 100644 index 151f6f0..0000000 --- a/Oasis/requirement.txt +++ /dev/null @@ -1,3 +0,0 @@ -mpi4py==3.0.3 -numpy==1.18.4 -pip==20.1.1 \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index ad85a2c..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,6 +0,0 @@ -# This file was generated automatically from conda-smithy. To update this configuration, -# update the conda-forge.yml and/or the recipe/meta.yaml. -# -*- mode: yaml -*- - -jobs: - - template: ./.azure-pipelines/azure-pipelines-linux.yml \ No newline at end of file diff --git a/conda-forge.yml b/conda-forge.yml deleted file mode 100644 index a0ff807..0000000 --- a/conda-forge.yml +++ /dev/null @@ -1,12 +0,0 @@ -recipe_dir: recipe -skip_render: - - README.md - - LICENSE.txt - - .gitattributes - - .gitignore - - build-locally.py - - LICENSE - - .github/CONTRIBUTING.md - - .github/ISSUE_TEMPLATE.md - - .github/PULL_REQUEST_TEMPLATE.md - - .github/workflows \ No newline at end of file diff --git a/conda-forge/Oasis/LICENSE.txt b/conda-forge/Oasis/LICENSE.txt deleted file mode 100644 index 484d184..0000000 --- a/conda-forge/Oasis/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -## MIT License - -Copyright (c) 2018 Mostafa - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/conda-forge/Oasis/meta.yaml b/conda-forge/Oasis/meta.yaml deleted file mode 100644 index adc9c81..0000000 --- a/conda-forge/Oasis/meta.yaml +++ /dev/null @@ -1,44 +0,0 @@ -{% set name = "Oasis" %} -{% set version = "1.0.0" %} - -package: - name: {{ name|lower }} - version: {{ version }} - -source: - url : https://github.com/MAfarrag/Oasis/archive/{{ version }}.tar.gz - sha256: 3156b3eabe0d3759d923b7ca432b21e865fc6528b699cd315340105dd8d631bf - -build: - noarch: python - number: 0 - script: '{{ PYTHON }} -m pip install . -vv' - -requirements: - host: - - python >=2.7 - - pip - - numpy - run: - - python >=2.7 - - pip - - numpy - -test: - imports: - - Oasis - -about: - home: https://github.com/MAfarrag/HAPI/ - license: BSD-3-Clause - license_family: BSD - license_file: LICENSE.txt - summary: 'Harmony Search Optimization Algorithm' - description: | - Harmony Search Optimization Algorithm. - dev_url: https://github.com/MAfarrag/Oasis - doc_url: https://oasis-optimization.readthedocs.io/ - -extra: - recipe-maintainers: - - MAfarrag diff --git a/conda/bld.bat b/conda/bld.bat deleted file mode 100644 index 6021130..0000000 --- a/conda/bld.bat +++ /dev/null @@ -1,2 +0,0 @@ -"%PYTHON%" setup.py install -if errorlevel 1 exit 1 \ No newline at end of file diff --git a/conda/build.sh b/conda/build.sh deleted file mode 100644 index fec5047..0000000 --- a/conda/build.sh +++ /dev/null @@ -1 +0,0 @@ -$PYTHON setup.py install # Python command to install the script. \ No newline at end of file diff --git a/conda/meta.yaml b/conda/meta.yaml deleted file mode 100644 index 02ff1f5..0000000 --- a/conda/meta.yaml +++ /dev/null @@ -1,45 +0,0 @@ -{% set version = "1.0.0" %} - -package: - name: oasis - version: {{ version }} - -source: - path: F:\01Algorithms\Optimization\OASIS - -build: - noarch: python - number: 0 - script: python -m pip install --no-deps --ignore-installed . - -requirements: - host: -# - ca-certificates=2020.4.5.1=hecc5488_0 -# - certifi=2020.4.5.1=py37hc8dfbb8_0 - - pip - - python - - numpy - #- pip: - #- mpi4py - run: -# - ca-certificates=2020.4.5.1=hecc5488_0 -# - certifi=2020.4.5.1=py37hc8dfbb8_0 - - pip - - python - - numpy - #- pip: - #- mpi4py - -test: - imports: - - Oasis - -about: - home: https://github.com/MAfarrag/Oasis - license: MIT - summary: 'Harmony Search Optimization Algorithm' - description: | - Harmony Search Optimization Algorithm. - dev_url: https://github.com/MAfarrag/Oasis - doc_url: https://github.com/MAfarrag/Oasis - doc_source_url: https://github.com/MAfarrag/Oasis/master/README.md \ No newline at end of file diff --git a/environment.yml b/environment.yml index 7a321db..6240f23 100644 --- a/environment.yml +++ b/environment.yml @@ -1,11 +1,5 @@ channels: - conda-forge dependencies: - - ca-certificates=2020.4.5.1=hecc5488_0 - - certifi=2020.4.5.1=py37hc8dfbb8_0 - pip - - python - - numpy - - pip: -# - mpi4py==3.0.3 - - git+https://github.com/MAfarrag/Oasis.git \ No newline at end of file + - numpy \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6ade40c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ +[project] +name = "Oasis-Optimization" +version = "1.0.3" +description = "Oasis is a Harmony search optimization algorithm." +readme = {file = "README.md", content-type = "text/markdown"} +authors = [ + {name = "Mostafa Farrag", email = "moah.farag@gmail.come"} +] +license = {text = "GNU General Public License v3"} + +keywords = ["Optimization", "Harmony Search"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Natural Language :: English", + "Programming Language :: Python", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Software Development", +] + +requires-python = ">=3.0" + +dependencies =[ + "numpy >=2.0.0" +] + +[project.optional-dependencies] +test = [ + "pytest >= 8.2.2", + "pytest-cov >= 6.0.0", + "nbval >= 0.11.0", + "coverage" +] + +[tool.setuptools] + +[tool.setuptools.packages.find] +where = ["src"] +include = ["Oasis", "Oasis.*"] + +[project.urls] +homepage = "https://github.com/MAfarrag/Oasis" + +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/recipe/meta - Copy.yaml b/recipe/meta - Copy.yaml deleted file mode 100644 index 1698d7a..0000000 --- a/recipe/meta - Copy.yaml +++ /dev/null @@ -1,52 +0,0 @@ -{% set name = "oasis" %} -{% set version = "0.1.1" %} - -package: - name: {{ name|lower }} - version: {{ version }} - -source: - path: F:\01Algorithms\Oasis\dist\Oasis-Optimization-0.1.1.tar.gz - sha256: f89372a92069d83f4392f652e9f1bb3679a432c3a3670f7450998789dbdb3cbe - - -build: - noarch: python - number: {{ environ.get('GIT_DESCRIBE_NUMBER', '0') }} - string: {{ [build_number, ('h' + PKG_HASH), environ.get('GIT_DESCRIBE_HASH', '')]|join('_') }} - script: "{{ PYTHON }} -m pip install . -vv" - -requirements: - build: - host: - - ca-certificates=2020.4.5.1=hecc5488_0 - - certifi=2020.4.5.1=py37hc8dfbb8_0 - - pip - - python - - numpy - run: - - ca-certificates=2020.4.5.1=hecc5488_0 - - certifi=2020.4.5.1=py37hc8dfbb8_0 - - pip - - python - - numpy - -test: - imports: - - Oasis - commands: - - OASIS --help - - pytest - requires: - - pytest - source_files: - - tests/ - -about: - home: https://github.com/conda-forge/Oasis - license: BSD-3-Clause - license_family: BSD - license_file: LICENSE - dev_url: https://github.com/MAfarrag/Oasis - doc_url: https://github.com/MAfarrag/Oasis - doc_source_url: https://github.com/MAfarrag/Oasis/master/README.md \ No newline at end of file diff --git a/recipe/meta.yaml b/recipe/meta.yaml deleted file mode 100644 index 2ae6608..0000000 --- a/recipe/meta.yaml +++ /dev/null @@ -1,52 +0,0 @@ -{% set name = "oasis" %} -{% set version = "0.1.1" %} - -package: - name: {{ name|lower }} - version: {{ version }} - -source: - url: https://files.pythonhosted.org/packages/a4/9f/c5ada33d35d185b659411ef3331213ea85c37aa3c7aa023b5a546003518d/Oasis-Optimization-0.1.1.tar.gz - sha256: f89372a92069d83f4392f652e9f1bb3679a432c3a3670f7450998789dbdb3cbe - - -build: - noarch: python - number: 0 - string: {{ [build_number, ('h' + PKG_HASH), environ.get('GIT_DESCRIBE_HASH', '')]|join('_') }} - script: "{{ PYTHON }} -m pip install . -vv" - -requirements: - build: - host: - - ca-certificates=2020.4.5.1=hecc5488_0 - - certifi=2020.4.5.1=py37hc8dfbb8_0 - - pip - - python - - numpy - run: - - ca-certificates=2020.4.5.1=hecc5488_0 - - certifi=2020.4.5.1=py37hc8dfbb8_0 - - pip - - python - - numpy - -test: - imports: - - Oasis - commands: - - OASIS --help - - pytest - requires: - - pytest - source_files: - - tests/ - -about: - home: https://github.com/conda-forge/Oasis - license: BSD-3-Clause - license_family: BSD - license_file: LICENSE - dev_url: https://github.com/MAfarrag/Oasis - doc_url: https://github.com/MAfarrag/Oasis - doc_source_url: https://github.com/MAfarrag/Oasis/master/README.md \ No newline at end of file diff --git a/requirement.txt b/requirement.txt deleted file mode 100644 index 79f19d1..0000000 --- a/requirement.txt +++ /dev/null @@ -1,4 +0,0 @@ -python -pip -numpy - diff --git a/setup.py b/setup.py deleted file mode 100644 index 69cf5ea..0000000 --- a/setup.py +++ /dev/null @@ -1,33 +0,0 @@ -from setuptools import setup , find_packages - -with open("README.md", "r") as fh: - long_description = fh.read() - -setup( - name='Oasis-Optimization', - version='1.0.2', - description='Optimization Algorithm', - author='Mostafa Farrag', - author_email='moah.farag@gmail.come', - url='https://github.com/MAfarrag/Oasis', - keywords=['Optimization', 'Harmony Search'], - long_description=long_description, - long_description_content_type="text/markdown", - License="MIT" , - zip_safe=False, - packages=find_packages(), - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Natural Language :: English', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Topic :: Software Development', - ] - ) \ No newline at end of file diff --git a/Oasis/__init__.py b/src/Oasis/__init__.py similarity index 54% rename from Oasis/__init__.py rename to src/Oasis/__init__.py index ddb1729..de2b874 100644 --- a/Oasis/__init__.py +++ b/src/Oasis/__init__.py @@ -3,40 +3,6 @@ __docformat__ = 'restructuredtext' -# import os,sys - -from numpy.distutils.core import setup -from numpy.distutils.misc_util import Configuration - - -# def configuration(parent_package, top_path): - -# config = Configuration('Oasis', parent_package, top_path) - -# # need: auto add_subpackage from source availability -# config.add_subpackage('NSGA') - -# return config - -# setup(**configuration(top_path='').todict()) - -def configuration(parent_package='',top_path=None): - - from numpy.distutils.misc_util import Configuration - - config = Configuration(None,parent_package,top_path) - config.set_options( - ignore_setup_xxx_py=True, - assume_default_configuration=True, - delegate_options_to_subpackages=True, - quiet=True, - ) - -# config.add_subpackage('NSGA') - config.add_subpackage('HS') - - return config - import Oasis.constraint as constraint import Oasis.objective as objective import Oasis.variable as variable @@ -47,12 +13,8 @@ def configuration(parent_package='',top_path=None): import Oasis.optimizer as optimizer -# import Oasis.hsapi as hsapi -# from Oasis.HS import * -import Oasis.harmonysearch as harmonysearch -#import Oasis.ga as ga -# from Oasis.NSGA import * +import Oasis.harmonysearch as harmonysearch # module level doc-string __doc__ = """ diff --git a/Oasis/constraint.py b/src/Oasis/constraint.py similarity index 100% rename from Oasis/constraint.py rename to src/Oasis/constraint.py diff --git a/Oasis/gradient.py b/src/Oasis/gradient.py similarity index 100% rename from Oasis/gradient.py rename to src/Oasis/gradient.py diff --git a/Oasis/harmonysearch/__init__.py b/src/Oasis/harmonysearch/__init__.py similarity index 100% rename from Oasis/harmonysearch/__init__.py rename to src/Oasis/harmonysearch/__init__.py diff --git a/Oasis/harmonysearch/hs.py b/src/Oasis/harmonysearch/hs.py similarity index 100% rename from Oasis/harmonysearch/hs.py rename to src/Oasis/harmonysearch/hs.py diff --git a/Oasis/harmonysearch/hsapi.py b/src/Oasis/harmonysearch/hsapi.py similarity index 99% rename from Oasis/harmonysearch/hsapi.py rename to src/Oasis/harmonysearch/hsapi.py index 9e2a409..d526f2c 100644 --- a/Oasis/harmonysearch/hsapi.py +++ b/src/Oasis/harmonysearch/hsapi.py @@ -180,7 +180,7 @@ def objconfunc(x, *args, **kwargs): fail = 0 ff = [] gg = [] - if (myrank == 0): + if myrank == 0: if self.hot_start: [vals,hist_end] = hos_file.read(ident=['obj', 'con', 'fail']) if hist_end: @@ -197,7 +197,7 @@ def objconfunc(x, *args, **kwargs): [ff,gg,fail] = opt_problem.obj_fun(xn, *args, **kwargs) # Store History - if (myrank == 0): + if myrank == 0: if self.sto_hst: log_file.write(x,'x') log_file.write(ff,'obj') @@ -259,7 +259,6 @@ def objconfunc(x, *args, **kwargs): # Constraints Handling m = len(opt_problem.constraints.keys()) me = 0 - #i = 0 if m > 0: for key in opt_problem.constraints.keys(): if opt_problem.constraints[key].type == 'e': @@ -284,7 +283,7 @@ def objconfunc(x, *args, **kwargs): itol = self.options['itol'][1] atol = self.options['atol'][1] rtol = self.options['rtol'][1] - if (myrank == 0): + if myrank == 0: oout = self.options['prtoutiter'][1] iout = self.options['prtinniter'][1] else: @@ -342,7 +341,7 @@ def objconfunc(x, *args, **kwargs): sol_time = time.time() - t0 - if (myrank == 0): + if myrank == 0: if self.sto_hst: log_file.close() if tmp_file: diff --git a/Oasis/history.py b/src/Oasis/history.py similarity index 91% rename from Oasis/history.py rename to src/Oasis/history.py index 39500eb..8cc9e28 100644 --- a/Oasis/history.py +++ b/src/Oasis/history.py @@ -49,9 +49,9 @@ def __init__(self, filename, mode, optimizer=None, opt_prob=None, *args, **kwarg else: if not os.path.isfile(bin_name): - raise NameError('Error: filename %s.bin does not exist'%(filename)) + raise NameError('Error: filename %s.bin does not exist' % filename) if not os.path.isfile(cue_name): - raise NameError('Error: filename %s.cue does not exist'%(filename)) + raise NameError('Error: filename %s.cue does not exist' % filename) @@ -60,7 +60,7 @@ def __init__(self, filename, mode, optimizer=None, opt_prob=None, *args, **kwarg if self.mode == 'w': - if optimizer == None: + if optimizer is None: optname = 'None' else: optname = optimizer.name @@ -120,33 +120,33 @@ def read(self, index=[], ident=['obj']): bdata[id] = [] if id in self.cues.keys(): if isinstance(index,int): - if (index == -1): + if index == -1: index = len(self.cues[id])-1 index = [index, index+1] elif isinstance(index,list): - if (index == []): + if index == []: index = [self.icount[id], self.icount[id]+1] self.icount[id] += 1 - elif (index == [0,-1]): + elif index == [0, -1]: index = [0, len(self.cues[id])] else: raise ValueError('Index type not understood - must be either int or list') else: hist_end = True - return (bdata,hist_end) + return bdata, hist_end for i in range(index[0],index[1]): # - if (i >= len(self.cues[id])): + if i >= len(self.cues[id]): hist_end = True - return (bdata,hist_end) + return bdata, hist_end tvals = ARRAY.array('d') self.bin_file.seek(self.cues[id][i][0]*8,0) tvals.fromfile(self.bin_file,self.cues[id][i][1]) bdata[id].append(numpy.array(tvals)) - return (bdata, hist_end) + return bdata, hist_end def write(self,bin_data,cue_data): diff --git a/Oasis/objective.py b/src/Oasis/objective.py similarity index 100% rename from Oasis/objective.py rename to src/Oasis/objective.py diff --git a/Oasis/optimization.py b/src/Oasis/optimization.py similarity index 100% rename from Oasis/optimization.py rename to src/Oasis/optimization.py diff --git a/Oasis/optimizer.py b/src/Oasis/optimizer.py similarity index 98% rename from Oasis/optimizer.py rename to src/Oasis/optimizer.py index 1be7a3d..93ed7d5 100644 --- a/Oasis/optimizer.py +++ b/src/Oasis/optimizer.py @@ -93,7 +93,7 @@ def __call__(self, opt_problem={}, *args, **kwargs): if first_ieq == -1: first_ieq = int(key) - if last_eq > first_ieq and first_ieq != -1: + if last_eq > first_ieq != -1: print('WARNING - Equality Constraints should be defined BEFORE Inequality Constraints') # Solve Optimization Problem @@ -258,7 +258,7 @@ def _setHistory(self, probname, store_hst, hot_start, def_fname): # hot_start is string elif store_hst: if isinstance(hot_start,str): - if (hot_start == def_fname): + if hot_start == def_fname: hos_file = History(hot_start, 'r', self) log_file = History(def_fname+'_tmp', 'w', self, probname) tmp_file = True diff --git a/Oasis/parameter.py b/src/Oasis/parameter.py similarity index 100% rename from Oasis/parameter.py rename to src/Oasis/parameter.py diff --git a/Oasis/variable.py b/src/Oasis/variable.py similarity index 100% rename from Oasis/variable.py rename to src/Oasis/variable.py diff --git a/tests/test.py b/tests/test.py deleted file mode 100644 index d6a27e5..0000000 --- a/tests/test.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Sun Jan 19 16:34:44 2020 - -@author: mofarrag -""" -import Oasis - -#try: -# import Hapi -#except ImportError: -# try: -# import HAPI -# except ImportError: -# import sys -# sys.path.append(".") -# import Hapi diff --git a/tests/test_import.py b/tests/test_import.py new file mode 100644 index 0000000..e85b6c1 --- /dev/null +++ b/tests/test_import.py @@ -0,0 +1,4 @@ + +def test_import(): + import Oasis + print("Successfully imported Oasis") \ No newline at end of file