diff --git a/CHANGELOG.md b/CHANGELOG.md index 9852239dc211666580b44bef0b7984b4b196d15f..88b5938de3c88d1e4a31ad6981e5224a035034ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,10 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 respectively. * `BadQueryError`, `EmptyUniqueQueryError`, and `QueryNotUniqueError` for bad (unique) queries. -* Versioning support (experimental). The version db.Version class can - represents particular entity versions and also the complete history of an - entity. -* Automated documentation builds: `make doc` +* Added `cache` paramter to `execute_query` and `Query.execute` which indicates + whether server may use the cache for the query execution. +* Added `cached` property to the `Query` class which indicates whether the + server used the cache for the execution of the last query. ### Changed ### @@ -44,6 +44,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `get_something` functions from all error object in `exceptions.py` * `AmbiguityException` + +### Fixed ### + +### Security ### + +## [0.4.1] - 2021-02-10 ## + +### Added ### + +* Versioning support (experimental). The version db.Version class can + represents particular entity versions and also the complete history of an + entity. +* Automated documentation builds: `make doc` + +### Changed ### + +### Deprecated ### + +### Removed ### + ### Fixed ### * deepcopy of `_Messages` objects @@ -103,7 +123,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * import bugs in apiutils -## [0.2.4] -- 2020-04-23 +## [0.2.4] - 2020-04-23 ### Added diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md new file mode 100644 index 0000000000000000000000000000000000000000..04e783a7fa31b1d5c3a600a1009c8f040db1620d --- /dev/null +++ b/DEPENDENCIES.md @@ -0,0 +1,6 @@ +* caosdb-server == 0.3 +* Python >= 3.5 +* pip >= 20.0.2 + + +Any other dependencies are being installed via pip diff --git a/README.md b/README.md index ef26a604905d5140ae9a775065002af35ffe2121..e44702a3a22c28af986d641b5d7e454f915326c8 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ project](https://gitlab.com/caosdb/caosdb) for more information. # License -Copyright (C) 2018 Research Group Biomedical Physics, Max Planck Institute for -Dynamics and Self-Organization Göttingen. -Copyright (C) 2020 Indiscale GmbH <info@indiscale.com> +* Copyright (C) 2018 Research Group Biomedical Physics, Max Planck Institute + for Dynamics and Self-Organization Göttingen. +* Copyright (C) 2020-2021 Indiscale GmbH <info@indiscale.com> All files in this repository are licensed under a [GNU Affero General Public License](LICENCE.md) (version 3 or later). diff --git a/RELEASE_GUIDELINES.md b/RELEASE_GUIDELINES.md index 02be5c1ad19f6a3a405fb08d62e23dab350ad445..dd6d5af4c43e1eea17c70f29da837c905694fed4 100644 --- a/RELEASE_GUIDELINES.md +++ b/RELEASE_GUIDELINES.md @@ -16,21 +16,27 @@ guidelines of the CaosDB Project 1. Create a release branch from the dev branch. This prevents further changes to the code base and a never ending release process. Naming: `release-<VERSION>` -2. Check all general prerequisites. +2. Update CHANGELOG.md -3. Prepare [setup.py](./setup.py): Update the `MAJOR`, `MINOR`, `MICRO`, `PRE` +3. Check all general prerequisites. + +4. Prepare [setup.py](./setup.py): Check the `MAJOR`, `MINOR`, `MICRO`, `PRE` variables and set `ISRELEASED` to `True`. Use the possibility to issue pre-release versions for testing. -4. Merge the release branch into the master branch. +5. Merge the release branch into the master branch. -5. Tag the latest commit of the master branch with `v<VERSION>`. +6. Tag the latest commit of the master branch with `v<VERSION>`. -6. Delete the release branch. +7. Delete the release branch. -7. Remove possibly existing `./dist` directory with old release. +8. Remove possibly existing `./dist` directory with old release. -8. Publish the release by executing `./release.sh` with uploads the caosdb +9. Publish the release by executing `./release.sh` with uploads the caosdb module to the Python Package Index [pypi.org](https://pypi.org). -9. Merge the master branch back into the dev branch. +10. Merge the master branch back into the dev branch. + +11. After the merge of master to dev, start a new development version by + setting `ISRELEASED` to `False` and by increasing at least the `MIRCO` + version in [setup.py](./setup.py) diff --git a/release.sh b/release.sh index a5f3654291743e5ac22fd3b938719e294b3a1e90..1af097f014de6cd9eb3d3e8ba5da34aea0fe1671 100755 --- a/release.sh +++ b/release.sh @@ -1,4 +1,4 @@ #!/bin/bash -rm -r dist/ build/ .eggs/ +rm -rf dist/ build/ .eggs/ python setup.py sdist bdist_wheel python -m twine upload -s dist/* diff --git a/setup.py b/setup.py index 4ab2d7669cc4f6d3f4873c0265da6c8cf06932ba..9c638fbc88eed39f263d4d90652685ba4db984af 100755 --- a/setup.py +++ b/setup.py @@ -46,8 +46,8 @@ from setuptools import find_packages, setup ######################################################################## MAJOR = 0 -MINOR = 4 -MICRO = 1 +MINOR = 5 +MICRO = 0 PRE = "" # e.g. rc0, alpha.1, 0.beta-23 ISRELEASED = False diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index cd0683ed5e4ec7a6e61f7474ec9e58e3878e24bc..28911443392f76191ea0c7ca6c212a39d5d52184 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -3628,6 +3628,23 @@ class ACL(): class Query(): + """Query + + Attributes + ---------- + q : str + The query string. + flags : dict of str + A dictionary of flags to be send with the query request. + messages : _Messages() + A container of messages included in the last query response. + cached : bool + indicates whether the server used the query cache for the execution of + this query. + results : int or Container + The number of results (when this was a count query) or the container + with the resulting entities. + """ def putFlag(self, key, value=None): self.flags[key] = value @@ -3643,10 +3660,12 @@ class Query(): def __init__(self, q): self.flags = dict() self.messages = _Messages() + self.cached = None if isinstance(q, etree._Element): self.q = q.get("string") self.results = int(q.get("results")) + self.cached = q.get("cached").lower() == "true" for m in q: if m.tag.lower() == 'warning' or m.tag.lower() == 'error': @@ -3654,17 +3673,43 @@ class Query(): else: self.q = q - def execute(self, unique=False, raise_exception_on_error=True, - **kwargs): + def execute(self, unique=False, raise_exception_on_error=True, cache=True): + """Execute a query (via a server-requests) and return the results. + + Parameters + ---------- + + unique : bool + Whether the query is expected to have only one entity as result. + Defaults to False. + raise_exception_on_error : bool + Whether an exception should be raises when there are errors in the + resulting entities. Defaults to True. + cache : bool + Whether to use the query cache (equivalent to adding a "cache" + flag) to the Query object. Defaults to True. + + Returns + ------- + results : Container or integer + Returns an integer when it was a `COUNT` query. Otherwise, returns a + Container with the resulting entities. + """ connection = get_connection() - query_dict = dict(self.flags) + + flags = self.flags + if cache is False: + flags["cache"] = "false" + query_dict = dict(flags) query_dict["query"] = str(self.q) + _log_request("GET Entity?" + str(query_dict), None) http_response = connection.retrieve( entity_uri_segments=["Entity"], - query_dict=query_dict, **kwargs) + query_dict=query_dict) cresp = Container._response_to_entities(http_response) self.results = cresp.query.results + self.cached = cresp.query.cached if self.q.lower().startswith('count') and len(cresp) == 0: # this was a count query @@ -3691,8 +3736,32 @@ class Query(): return cresp -def execute_query(q, unique=False, raise_exception_on_error=True, flags=None, - **kwargs): +def execute_query(q, unique=False, raise_exception_on_error=True, cache=True, flags=None): + """Execute a query (via a server-requests) and return the results. + + Parameters + ---------- + + q : str + The query string. + unique : bool + Whether the query is expected to have only one entity as result. + Defaults to False. + raise_exception_on_error : bool + Whether an exception should be raises when there are errors in the + resulting entities. Defaults to True. + cache : bool + Whether to use the query cache (equivalent to adding a "cache" flag). + Defaults to True. + flags : dict of str + Flags to be added to the request. + + Returns + ------- + results : Container or integer + Returns an integer when it was a `COUNT` query. Otherwise, returns a + Container with the resulting entities. + """ query = Query(q) if flags is not None: @@ -3700,7 +3769,7 @@ def execute_query(q, unique=False, raise_exception_on_error=True, flags=None, return query.execute(unique=unique, raise_exception_on_error=raise_exception_on_error, - **kwargs) + cache=cache) class DropOffBox(list):