Skip to content

Commit

Permalink
Dev (#74)
Browse files Browse the repository at this point in the history
* add flake8 config to pyproject.toml, add flake8-docstrings plugin to repo, add .pylintrc config from Google

* add flake8 config, remove flake9 and use normal flake8 with own .flake8 config file

* first functions for downloading cube files

* update

* no verification

* pylint fixes

* add simple test cases for _handle_status_code

* update line length from 80 to 120, change indentation from 2 to 4

* activate more rules

* fix pylint errors

* fix pylint errors

* fix missing dependencies

* fix mypy errors

* remove unncessary code

* fix pylint issues

* fix pylint config issues

* add missing dependencies to .toml

* fix import error

* fix jsondecode error

* add demo notebook for tablefile endpoint

* fix return type issue

* adjust error message for http_helper

* fix column header issues

* remove unncessary cut footer function

* integrate PR feedback

* update unit tests

* refactor http_helper module

* set area to optional parameter

* fix typo

* debug failing unit tests

* debug failing unit tests

* add .env

* restore config_loader.py

* integrate feedback from PR

* integrate PR feedback

* remove dotenv, use configparser instead (standard library)

implement a user config using configparser module

upload created doc as artifact

update module docstring

* merge tablefile and cubefile PR and use latest config module

* [#43] Cache downloaded data; Implement feature with decorator; added tests

* fix pylint errors; refactor code so that common code for downloading data is now in data.py module and table.py and cube.py only hold specific parsing logic

* remove helper methods from get_data, move logic to the individual moduls

* added clean_cache function

function that removes all files from cache directory or only one, specified by name. Likely to be moved to cache.py, once this is on dev

* Added ToDos, Unified query param comparison

* Updated destatis status check #45

Incorporated further response codes and response type checks.
Output for Code 0 tbd

* Merged updates from personal branch

* Added http 5xx error check, added destatis status tests

* Updated urls, unified Destatis type-style

* Added generic response creation for generic http_helper test

* Updated type hints, made contents rely on functionality from http_helpers

* Merged changes from draft branch, including pylint fixes, Exception and Error clarification. Also moved clean_cache function. Some ToDos still left, #45.

* fixed linting issues, including inconsistent returns.

* hotfix of overlooked error #45.

* narrowed the catched exception

* Updated clean_cache, updated http_helper

* Fix lint issue with assert

* mypy fixes for ci/cd pipeline #45

* Updated clean_cache function, added a first version of a test

* Fixed linting issues, #45

* updated with remarks from pull request #45, #46

* updated logging due to linting errors W1203

* Improved test coverage, update temporary test directory for user names with spaces and non-latin characters, added mocked API call, added mocked create_settings call, moved test_http_helper, added TODOs for the future, #45

* Added mock as dependency (as otherwise CI/CD understandably fails), #45

* Also update project.lock, forgot it before, #45

* Fixed missing config dict error (in remote CI/CD) by mocking it, moved load_config into function, #45

* Fixed missing config dict error (in remote CI/CD) by mocking it, moved load_config into function, #45

* Fixed safety issues (mako and dparse) by updating poetry.lock, #45

* Fixed linting issue: timeout for requests.get added, #45

* Feat/update cube format (#67)

* update cube module to handle cubes with more than one value variable in DQI. Add correct types to value columns so they are no longer of type object.

* introduce Table und Cube class for coherent and simplified user interface; both classes download data with get_data() and provide access to data via .data and access to metadata via .metadata. Cube has .cube in addition for special cube metadata

* reimplement cache for download data from endpoint

* use compression for caching data

* new tests for cube module

* add tests for cache decorator that is called with functions that don't use the data endpoint (expect no caching)

* find endpoint (#66)

* simple example of Statistic class

* first version of parsing cube; added pandas and notebook to dependencies

* adding find and hierarchy

* adding find and hierarchy

* adding find and hierarchy

* adding find and hierarchy

* created results class

* created results class

* created results class

* updated Results class with get_metadata for statistics and variables

* updated string to f-strings according to pylint

* solved pylint issues

* solved pylint issues

* solved pylint issues

* several improvements based on feedback for PR #66

* several improvements based on feedback for PR #66

* several improvements based on feedback for PR #66

* modified docstring

* modified docstring

Co-authored-by: Michael Aydinbas <[email protected]>

* Feat/refactor cache (#68)

* refactor cache; no longer a decorator function but part of the new `load_data` function. This function checks if there is a hit in cache and loads the data from there, or load the data per request from Destatis. The new cache function stores data under `<name>/<endpoint>/<method>/hash(<request-params>)/<date-today>.zip` so different params will be cached differently

`load_data` has a new parameter `as_json`, which defaults to `False`, so that the response is returned as raw text. However, setting `as_json=True` will return the response as a parsed JSON dict.

* Feature/#48 hello world and profile endpoint (#69)

* added clean_cache function

function that removes all files from cache directory or only one, specified by name. Likely to be moved to cache.py, once this is on dev

* Added ToDos, Unified query param comparison

* Updated destatis status check #45

Incorporated further response codes and response type checks.
Output for Code 0 tbd

* Merged updates from personal branch

* Added http 5xx error check, added destatis status tests

* Updated urls, unified Destatis type-style

* Added generic response creation for generic http_helper test

* Updated type hints, made contents rely on functionality from http_helpers

* merged current dev into feature branch.

* Merged changes from draft branch, including pylint fixes, Exception and Error clarification. Also moved clean_cache function. Some ToDos still left, #45.

* fixed linting issues, including inconsistent returns.

* hotfix of overlooked error #45.

* narrowed the catched exception

* Updated clean_cache, updated http_helper

* Fix lint issue with assert

* mypy fixes for ci/cd pipeline #45

* Updated clean_cache function, added a first version of a test

* Fixed linting issues, #45

* updated with remarks from pull request #45, #46

* updated logging due to linting errors W1203

* Added most of the methods from helloworld and profile endpoint, without tests so far, #48

* Modified pre-commit hook (set black profile for isort) to avoid isort and black conflicting changes

* Added most of the methods from helloworld and profile endpoint - this time for real, without tests so far, #48

* Merged current dev into feature branch, #48

* Updated line-length argument for isort, added tests for helloworld and profile, #48

* merged dev again and fixed merge conflicts for automatic merge, #48

* Implemented removeresult + test, #48.

* updated profile password test, #48, still isort issues seem ominous.

* fixed isort in run tests to same line-length as used in pre-commit-config to avoid reoccuring conflicts in profile, #48, see also #60.

* Fix W0707 raise ... from, #48.

* Fix mypy type-hinting error, #48.

* Minor requested updates, #48.

* fixed mypy type, #48.

* isort toml configuration commit (check line-length specification at only one point)

* fixed line-length -> line_length

* Added notebooks for helloworld and profile endpoint functions, updated get_data_from_endpoint to load_data as requested, #48.

* fixed profile function text outputs, fixed tests, #48.

* Added casting for mypy/ ci/cd, #48

* Feat/improve cache (#71)

* refactor cache to work properly for jobs: no longer cache endpoint and method but only name as identifier, so a cache hit happens when the unique name is found in the cache data, irrelevant of the endpoint or method, thus working for data/resultfile and data/tablefile

* normalize an object name so we can strip off the job-id

* fix cicd

* fix cicd

* fix isort settings

* fix mypy issues

* add comments

* refactor all tests to use python-mock (#72)

* refactor all tests to use python-mock

* update mocks

* Feature/#40 automatic job query (#70)

* added clean_cache function

function that removes all files from cache directory or only one, specified by name. Likely to be moved to cache.py, once this is on dev

* Added ToDos, Unified query param comparison

* Updated destatis status check #45

Incorporated further response codes and response type checks.
Output for Code 0 tbd

* Merged updates from personal branch

* Added http 5xx error check, added destatis status tests

* Updated urls, unified Destatis type-style

* Added generic response creation for generic http_helper test

* Updated type hints, made contents rely on functionality from http_helpers

* merged current dev into feature branch.

* Merged changes from draft branch, including pylint fixes, Exception and Error clarification. Also moved clean_cache function. Some ToDos still left, #45.

* fixed linting issues, including inconsistent returns.

* hotfix of overlooked error #45.

* narrowed the catched exception

* Added notes w\ Felix regarding automatic job support, #40.

* Notebook for interaction & workflow with jobs

* integrating jobs into http_helper.pyÂ

* Simplified if selections, added TODO comments, added catches for fail cases, #40

* splitting up jobs function and writing first tests for user input

* work in progress

* changes in jobs params for faster tests

* Changes in job due to http_helper #43

* refactor: Updated & added documentation, identified Windows input issue, #40.

* Commit before merge of dev

* commit before PR

* last working commit, #40.

* seem to have fixed issue with destatis response, however, currently am timed out and can not finally check, #40.

* Fixed new implementation and updated jobs notebook. Code needs clean-up & tests need to be updated (for input), #40.

* changes with respect to first PR

* Removed user input, always starting job, test update, currently on timeout

* pylint changes

* commit before merge

* Code quality http_helper.py and tests

* pylint uand black changes

* removing _generic_status_dict()

* Changes due to bandit

* Changes due to mypy

* refactor load_data to handle jobs

* fix tests

* Removed one old comment, #40

Co-authored-by: MarcoHuebner <[email protected]>
Co-authored-by: Michael Aydinbas <[email protected]>

* update dependencies

* rename package to pystatis

* import all main functions into pystatis main namespace

* fix failing tests

* add authors and maintainers

* fix pyproject.toml

* Feat/56 57 final readme (#73)

* Updating README; add sections about Installation and first setup

* updated readme with main features, how to use and how to contribute.

* fix tests

* added new functions cube, table

Co-authored-by: dpleus <[email protected]>

Co-authored-by: frederik9 <[email protected]>
Co-authored-by: codehering <[email protected]>
Co-authored-by: MarcoHuebner <[email protected]>
Co-authored-by: Daniel Pleus <[email protected]>
Co-authored-by: Felix Schmitz <[email protected]>
Co-authored-by: dpleus <[email protected]>
  • Loading branch information
7 people authored Oct 12, 2022
1 parent 80a5a8a commit 6242bdf
Show file tree
Hide file tree
Showing 39 changed files with 6,866 additions and 429 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PYGENESIS_USERNAME=
PYGENESIS_PASSWORD=
27 changes: 3 additions & 24 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10"]
os: [ubuntu-18.04, macOS-latest, windows-latest]

steps:
Expand All @@ -39,7 +39,7 @@ jobs:
poetry install
- name: Run tests
run: |
poetry run pytest --cov=pygenesis tests
poetry run pytest --cov=pystatis tests
code-quality:
strategy:
fail-fast: false
Expand All @@ -62,7 +62,7 @@ jobs:
- name: Run black
run: poetry run black . --check
- name: Run isort
run: poetry run isort . --check-only --profile black
run: poetry run isort . --check-only
- name: Run flake8
run: poetry run flake8 src --output-file=flake8_report.txt
- name: Run pylint
Expand All @@ -73,24 +73,3 @@ jobs:
run: poetry run safety check
- name: Run mypy
run: poetry run mypy src
generate-doc:
strategy:
fail-fast: false
matrix:
python-version: [3.10.2]
poetry-version: [1.1.13]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run poetry image
uses: abatilo/[email protected]
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: poetry install
- name: Run pdoc3
run: poetry run pdoc3 ./src/pygenesis --html -o docs --skip-errors
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,7 @@ dmypy.json

# Pyre type checker
.pyre/


# VSC
.vscode
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ repos:
args: [--markdown-linebreak-ext=md]
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black", "--filter-files", "--line-length", "80"]
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.14.2
hooks:
Expand Down
54 changes: 6 additions & 48 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ignore=third_party

# Files or directories matching the regex patterns are skipped. The regex
# matches against base names, not paths.
ignore-patterns=
ignore-patterns=test_.*

# Pickle collected data for later comparisons.
persistent=no
Expand Down Expand Up @@ -52,47 +52,31 @@ confidence=
# --disable=W"
disable=abstract-method,
apply-builtin,
arguments-differ,
attribute-defined-outside-init,
backtick,
bad-option-value,
basestring-builtin,
buffer-builtin,
c-extension-no-member,
consider-using-enumerate,
cmp-builtin,
cmp-method,
coerce-builtin,
coerce-method,
delslice-method,
div-method,
duplicate-code,
eq-without-hash,
execfile-builtin,
file-builtin,
filter-builtin-not-iterating,
fixme,
getslice-method,
global-statement,
hex-method,
idiv-method,
implicit-str-concat-in-sequence,
import-error,
import-self,
import-star-module-level,
inconsistent-return-statements,
input-builtin,
intern-builtin,
invalid-str-codec,
locally-disabled,
long-builtin,
long-suffix,
map-builtin-not-iterating,
misplaced-comparison-constant,
missing-function-docstring,
metaclass-assignment,
next-method-called,
next-method-defined,
no-absolute-import,
no-else-break,
no-else-continue,
Expand All @@ -109,7 +93,6 @@ disable=abstract-method,
old-octal-literal,
old-raise-syntax,
parameter-unpacking,
print-statement,
raising-string,
range-builtin-not-iterating,
raw_input-builtin,
Expand All @@ -124,28 +107,15 @@ disable=abstract-method,
suppressed-message,
sys-max-int,
too-few-public-methods,
too-many-ancestors,
too-many-arguments,
too-many-boolean-expressions,
too-many-branches,
too-many-instance-attributes,
too-many-locals,
too-many-nested-blocks,
too-many-public-methods,
too-many-return-statements,
too-many-statements,
trailing-newlines,
trailing-whitespace,
unichr-builtin,
unicode-builtin,
unnecessary-pass,
unpacking-in-except,
useless-else-on-loop,
useless-object-inheritance,
useless-suppression,
using-cmp-argument,
wrong-import-order,
xrange-builtin,
zip-builtin-not-iterating,
zip-builtin-not-iterating


[REPORTS]
Expand All @@ -155,12 +125,6 @@ disable=abstract-method,
# mypackage.mymodule.MyReporterClass.
output-format=text

# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]". This option is deprecated
# and it will be removed in Pylint 2.0.
files-output=no

# Tells whether to display a full report or only the messages
reports=no

Expand Down Expand Up @@ -227,7 +191,7 @@ method-rgx=(?x)^(?:(?P<exempt>_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase

# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test)$
no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test|^_.*)$

# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
Expand Down Expand Up @@ -265,7 +229,7 @@ generated-members=
[FORMAT]

# Maximum number of characters on a single line.
max-line-length=80
max-line-length=120

# TODO(https://github.com/PyCQA/pylint/issues/3352): Direct pylint to exempt
# lines made too long by directives to pytype.
Expand All @@ -279,20 +243,14 @@ ignore-long-lines=(?x)(
# else.
single-line-if-stmt=yes

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=

# Maximum number of lines in a module
max-module-lines=99999

# String used as indentation unit. The internal Google style guide mandates 2
# spaces. Google's externaly-published style guide says 4, consistent with
# PEP 8. Here, we use 2 spaces, for conformity with many open-sourced Google
# projects (like TensorFlow).
indent-string=' '
indent-string=' '

# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
Expand Down
7 changes: 7 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright © 2022 Michael Aydinbas

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.
Loading

0 comments on commit 6242bdf

Please sign in to comment.