Skip to content

Commit d7bfe9e

Browse files
Adrok24AleksMatzigaLuksicchorngMatic Lubej
authored
Develop (#29)
* Applied balck and isort formatting, added flake8 linter * Flake8 to ignore resources.py * Moved .pylintrc into pyproject.toml and converted formats into f-strings and more * Resolved remaining pylint errors * Added CI actions * Switched link to reference main instead of master branch * Various minor typo fixes and removed EOCLOUD deployment reference * Feat/add pre commit hooks (#18) * Add pre-commit yml file *Add ensure_import for all the libraries in requirements * fix pyproject.toml file * Fix configurations *Fix qgisMinimumVersion in metadata file *Fix pyproject.toml * Remove added libraries, that will be done in other MR * Fix configurations files *Delete unnecesary nbqa configurations * Add tests for utils/time functions (#19) * Add tests for utils/time functions *Add typing for those functions *Edit pyproject.toml file * Add new test cases Fix docstrings * Add one more test case * Try adding a lean CI installation (#20) * try adding a lean CI installation * adjust installation procedure * Add tests for utils/common function (#21) * Add test qgis environment (#22) * Add test for basic qgis environment *Add TestInputs folder and a tiff file for testing *Add confest file with fixture *Add utilities function for input folder * Fix imports and clean utils/init * Add qgis libraries to requirements-dev * Skip tests that involve qgis environment * Skip the full module based on import condition * Refactor in test_qgis_environment * Add tests for utils/geo module (#23) * Add tests for utils/geo module *Add mark qgis_integration to CI * fix import module order * Add PyQt5 to requirements-dev * Revert ci_action configuration for tests, skip test at module levels if cant import qgis.core * fix test_utils_geo importorskip * Fix types in utils/geo module * Improve some types, and code style * Test pytest markers for qgis tests at github ci * revert to previous commit * Add tests for sentinelhubdockwidget (#24) * Add tests for sentinelhubdockwidget *Add a fixture to initialize a QgsApplication *Add auxiliary function to test click a button * Add importorskip to the new tests * Move import inside the qgis_app fixture * Move method inside the test_widget module to avoid issues with CI and qgis libraries * Move sh_widget to another fixture * Refactor Settings to inherit from QSettings (#25) * Refactor Settings to inherit from QSettings *Add typing *Add test cases for this class * include import in the fixture qsettings to avoid conflicts with the CI * Fix settings *remove auto_save *refactor copy method *Add test for copy method *Fix wrong typing * Fix scope in widget fixture * Fix type in settings copy method * Add test naming (#26) * Add test naming * add test_get_qgis_layer_name * add test_get_filename * fix relative import for test common and test time * fix pre-commit hook * Fix config path for the settings (#27) * Feat/set cdse as main endpoint (#28) * Change predefined url to cdse endpoint change oauth documentation to cdse docs Update metadata Update to version 2.0.1 * Fix link to oauth documentation * Clean code in session, ogc and remove unused user.py * Add dropdown menu to select the endpoint * Edit metadata of plugin * update link to docs * add missing indents --------- Co-authored-by: Matic Lubej <[email protected]> --------- Co-authored-by: AleksMat <[email protected]> Co-authored-by: Žiga Lukšič <[email protected]> Co-authored-by: chorng <[email protected]> Co-authored-by: Matic Lubej <[email protected]>
1 parent be254d7 commit d7bfe9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1258
-1130
lines changed

Diff for: .flake8

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
ignore = E203, W503
3+
exclude = .git, __pycache__, SentinelHub/resources.py
4+
max-line-length= 120
5+
max-complexity = 13
6+
per-file-ignores =
7+
# imported but unused
8+
__init__.py: F401

Diff for: .github/workflows/ci_action.yml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: build
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- "master"
8+
- "develop"
9+
schedule:
10+
# Schedule events are triggered by whoever last changed the cron schedule
11+
- cron: "5 0 * * *"
12+
13+
env:
14+
# The only way to simulate if-else statement
15+
CHECKOUT_BRANCH: ${{ github.event_name == 'schedule' && 'develop' || github.ref }}
16+
17+
jobs:
18+
check-pre-commit-hooks:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout branch
22+
uses: actions/checkout@v2
23+
with:
24+
ref: ${{ env.CHECKOUT_BRANCH }}
25+
26+
- name: Setup Python
27+
uses: actions/setup-python@v2
28+
with:
29+
python-version: "3.8"
30+
architecture: x64
31+
32+
- name: Prepare pre-commit validators
33+
run: |
34+
pip install pre-commit
35+
pre-commit install
36+
37+
- name: Check code compliance with pre-commit validators
38+
run: pre-commit run --all-files
39+
40+
test-on-github:
41+
runs-on: ubuntu-latest
42+
strategy:
43+
matrix:
44+
python-version:
45+
- "3.8"
46+
- "3.9"
47+
- "3.10"
48+
49+
steps:
50+
- name: Checkout branch
51+
uses: actions/checkout@v2
52+
with:
53+
ref: ${{ env.CHECKOUT_BRANCH }}
54+
55+
- name: Setup Python
56+
uses: actions/setup-python@v2
57+
with:
58+
python-version: ${{ matrix.python-version }}
59+
architecture: x64
60+
61+
- name: Install packages
62+
run: |
63+
sudo apt-get update
64+
pip install pytest
65+
pip install -r requirements.txt -r requirements-dev.txt
66+
67+
- name: Run tests
68+
run: pytest
69+
70+
mirror-to-gitlab:
71+
if: github.event_name == 'push'
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v1
75+
- name: Mirror + trigger CI
76+
uses: SvanBoxel/gitlab-mirror-and-ci-action@master
77+
with:
78+
args: "https://git.sinergise.com/eo/applications/qgis_sentinel_hub/"
79+
env:
80+
GITLAB_HOSTNAME: "git.sinergise.com"
81+
GITLAB_USERNAME: "github-action"
82+
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }}
83+
GITLAB_PROJECT_ID: "507"
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,6 @@ zip_build
118118

119119
# Repo with external package wheels
120120
external
121+
122+
.vscode
123+
symbology-style.db

Diff for: .pre-commit-config.yaml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: requirements-txt-fixer
7+
- id: trailing-whitespace
8+
- id: debug-statements
9+
- id: check-toml
10+
- id: check-yaml
11+
- id: check-merge-conflict
12+
- id: debug-statements
13+
14+
- repo: https://github.com/psf/black
15+
rev: 22.12.0
16+
hooks:
17+
- id: black
18+
language_version: python3
19+
20+
- repo: https://github.com/pycqa/isort
21+
rev: 5.12.0
22+
hooks:
23+
- id: isort
24+
name: isort (python)
25+
26+
- repo: https://github.com/PyCQA/autoflake
27+
rev: v2.0.0
28+
hooks:
29+
- id: autoflake
30+
args:
31+
[
32+
--remove-all-unused-imports,
33+
--in-place,
34+
--ignore-init-module-imports,
35+
]
36+
37+
- repo: https://github.com/pycqa/flake8
38+
rev: 6.0.0
39+
hooks:
40+
- id: flake8
41+
additional_dependencies:
42+
- flake8-bugbear
43+
- flake8-comprehensions
44+
- flake8-simplify
45+
- flake8-typing-imports

Diff for: SentinelHub/__init__.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
def classFactory(iface):
23-
""" Load SentinelHub class from file SentinelHub.
23+
"""Load SentinelHub class from file SentinelHub.
2424
2525
:param iface: A QGIS interface instance.
2626
:type iface: QgsInterface
@@ -31,10 +31,11 @@ def classFactory(iface):
3131

3232
# The following initializes UI
3333
from . import resources
34-
3534
from .utils.meta import ensure_import
36-
ensure_import('oauthlib')
37-
ensure_import('requests_oauthlib')
35+
36+
ensure_import("oauthlib")
37+
ensure_import("requests_oauthlib")
3838

3939
from .main import SentinelHubPlugin
40+
4041
return SentinelHubPlugin(iface)

Diff for: SentinelHub/constants.py

+45-49
Original file line numberDiff line numberDiff line change
@@ -7,97 +7,93 @@
77

88

99
class MessageType(Enum):
10-
""" Types of messages to display in a message bar
11-
"""
12-
INFO = 'Info', Qgis.Info
13-
WARNING = 'Warning', Qgis.Warning
14-
CRITICAL = 'Error', Qgis.Critical
15-
SUCCESS = 'Success', Qgis.Success
10+
"""Types of messages to display in a message bar"""
11+
12+
INFO = "Info", Qgis.Info
13+
WARNING = "Warning", Qgis.Warning
14+
CRITICAL = "Error", Qgis.Critical
15+
SUCCESS = "Success", Qgis.Success
1616

1717
@property
1818
def nice_name(self):
19-
""" Provides a nice name
20-
"""
19+
"""Provides a nice name"""
2120
return self.value[0]
2221

2322
@property
2423
def level(self):
25-
""" Provides a QGIS message flag
26-
"""
24+
"""Provides a QGIS message flag"""
2725
return self.value[1]
2826

2927

3028
class CrsType:
31-
""" Class containing CRS EPSG strings
32-
"""
33-
POP_WEB = 'EPSG:3857'
34-
WGS84 = 'EPSG:4326'
29+
"""Class containing CRS EPSG strings"""
30+
31+
POP_WEB = "EPSG:3857"
32+
WGS84 = "EPSG:4326"
3533

3634

3735
class _BaseParameter(Enum):
38-
""" A base class for parameters
39-
"""
36+
"""A base class for parameters"""
37+
4038
@property
4139
def url_param(self):
42-
""" Parameter to be used for service requests
43-
"""
40+
"""Parameter to be used for service requests"""
4441
return self.value[0]
4542

4643
@property
4744
def nice_name(self):
48-
""" Nice name to display in UI
49-
"""
45+
"""Nice name to display in UI"""
5046
return self.value[1]
5147

5248

5349
class ImagePriority(_BaseParameter):
54-
""" Image priority parameter for Sentinel Hub service
55-
"""
56-
MOST_RECENT = 'mostRecent', 'Most recent'
57-
LEAST_RECENT = 'leastRecent', 'Least recent'
58-
LEAST_CC = 'leastCC', 'Least cloud coverage'
50+
"""Image priority parameter for Sentinel Hub service"""
51+
52+
MOST_RECENT = "mostRecent", "Most recent"
53+
LEAST_RECENT = "leastRecent", "Least recent"
54+
LEAST_CC = "leastCC", "Least cloud coverage"
5955

6056

6157
class ImageFormat(_BaseParameter):
62-
""" Image formats
63-
"""
64-
PNG = 'image/png', 'PNG'
65-
JPEG = 'image/jpeg', 'JPEG'
66-
TIFF = 'image/tiff', 'TIFF'
58+
"""Image formats"""
59+
60+
PNG = "image/png", "PNG"
61+
JPEG = "image/jpeg", "JPEG"
62+
TIFF = "image/tiff", "TIFF"
6763

6864

6965
class BaseUrl:
70-
""" Base URLs of some of the Sentinel Hub service deployments
71-
"""
72-
MAIN = 'https://services.sentinel-hub.com'
73-
USWEST = 'https://services-uswest2.sentinel-hub.com'
74-
EOCLOUD = 'http://services.eocloud.sentinel-hub.com/v1/'
66+
"""Base URLs of some Sentinel Hub service deployments"""
67+
68+
MAIN = "https://sh.dataspace.copernicus.eu"
69+
SH_MAIN = "https://services.sentinel-hub.com"
70+
USWEST = "https://services-uswest2.sentinel-hub.com"
7571

7672

7773
class ServiceType:
78-
""" Types of service used in the plugin
79-
"""
80-
WMS = 'WMS'
81-
WCS = 'WCS'
82-
WMTS = 'WMTS'
83-
WFS = 'WFS'
74+
"""Types of service used in the plugin"""
75+
76+
WMS = "WMS"
77+
WCS = "WCS"
78+
WMTS = "WMTS"
79+
WFS = "WFS"
8480

8581

8682
AVAILABLE_SERVICE_TYPES = [ServiceType.WMS, ServiceType.WMTS, ServiceType.WFS]
8783

8884

8985
class TimeType(Enum):
90-
""" A type of time
91-
"""
92-
START_TIME = 'start_time'
93-
END_TIME = 'end_time'
86+
"""A type of time"""
87+
88+
START_TIME = "start_time"
89+
END_TIME = "end_time"
9490

9591

9692
class ExtentType(Enum):
97-
""" A type of map extend, either a current map bbox or a custom defined bbox
98-
"""
99-
CURRENT = 'current'
100-
CUSTOM = 'custom'
93+
"""A type of map extend, either a current map bbox or a custom defined bbox"""
94+
95+
CURRENT = "current"
96+
CUSTOM = "custom"
10197

10298

10399
DEFAULT_REQUEST_TIMEOUT = 30

Diff for: SentinelHub/dockwidget.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,24 @@
44

55
import os
66

7+
from PyQt5.QtCore import pyqtSignal
78
from PyQt5.QtWidgets import QDockWidget
89
from PyQt5.uic import loadUiType
9-
from PyQt5.QtCore import pyqtSignal
1010

11-
12-
FORM_CLASS, _ = loadUiType(os.path.join(os.path.dirname(__file__), 'dockwidget.ui'))
11+
FORM_CLASS, _ = loadUiType(os.path.join(os.path.dirname(__file__), "dockwidget.ui"))
1312

1413

1514
class SentinelHubDockWidget(QDockWidget, FORM_CLASS):
16-
""" The main widget class for interaction with UI
17-
"""
15+
"""The main widget class for interaction with UI"""
16+
1817
closingPlugin = pyqtSignal()
1918

2019
def __init__(self, parent=None):
21-
""" Constructor
22-
"""
20+
"""Constructor"""
2321
super().__init__(parent)
2422
self.setupUi(self)
2523

2624
def closeEvent(self, event):
27-
""" When plugin is closed
28-
"""
25+
"""When plugin is closed"""
2926
self.closingPlugin.emit()
3027
event.accept()

0 commit comments

Comments
 (0)