Selaa lähdekoodia

feat: fix pycodestyle

Joao Andre 1 vuosi sitten
vanhempi
säilyke
1dc18d2230

+ 1 - 1
src/taipy/_run.py

@@ -57,7 +57,7 @@ def _run(*services: _AppType, **kwargs) -> t.Optional[Flask]:
         return None
 
     if gui and rest:
-        gui._set_flask(rest._app)
+        gui._set_flask(rest._app)  # type: ignore
         return gui.run(**kwargs)
     else:
         app = rest or gui

+ 2 - 6
src/taipy/rest/Pipfile

@@ -4,21 +4,17 @@ verify_ssl = true
 name = "pypi"
 
 [packages]
-apispec = {extras = ["yaml"], version = "==5.0"}
+apispec = {extras = ["yaml"], version = "==6.3"}
 apispec-webframeworks = "==0.5.2"
-Flask-Migrate = ">=3.0"
 Flask-RESTful = ">=0.3.9"
-flask-marshmallow = ">=0.14"
-markupsafe = "==2.1.1"
-passlib = "==1.7.4"
 taipy-core = {ref = "develop", git = "https://github.com/avaiga/taipy-core.git"}
 flask = "==3.0.0"
+marshmallow = "==3.20.1"
 
 [dev-packages]
 tox = ">=3.24.5"
 black = "*"
 pytest = "*"
-pytest-factoryboy = "*"
 pre-commit = "*"
 pytest-mock = "*"
 pytest-cov = "*"

+ 4 - 4
src/taipy/rest/api/resources/cycle.py

@@ -77,7 +77,7 @@ class CycleResource(Resource):
                 This Python example requires the 'requests' package to be installed (`pip install requests`).
                 ```python
                 import requests
-                    response = requests.get("http://localhost:5000/api/v1/cycles/CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a")
+                    response = requests.get("http://localhost:5000/api/v1/cycles/CYCLE_223894_e019-b50b-4b9f-ac09-527a")
                     print(response)
                     print(response.json())
                 ```
@@ -156,9 +156,9 @@ class CycleResource(Resource):
                 This Python example requires the 'requests' package to be installed (`pip install requests`).
                 ```python
                 import requests
-                    response = requests.delete("http://localhost:5000/api/v1/cycles/CYCLE_797384_ef210412-af91-4f41-b6e8-74d1648edcba")
-                    print(response)
-                    print(response.json())
+                response = requests.delete("http://localhost:5000/api/v1/cycles/CYCLE_794_ef21-af91-4f41-b6e8-7648eda")
+                print(response)
+                print(response.json())
                 ```
                 `CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a` is the value of the  *cycle_id* parameter. It
                 represents the identifier of the Cycle we want to delete.

+ 9 - 5
src/taipy/rest/api/resources/datanode.py

@@ -32,10 +32,10 @@ from ..schemas import (
     GenericDataNodeConfigSchema,
     InMemoryDataNodeConfigSchema,
     JSONDataNodeConfigSchema,
+    MongoCollectionDataNodeConfigSchema,
     PickleDataNodeConfigSchema,
-    SQLTableDataNodeConfigSchema,
     SQLDataNodeConfigSchema,
-    MongoCollectionDataNodeConfigSchema,
+    SQLTableDataNodeConfigSchema,
 )
 
 ds_schema_map = {
@@ -612,15 +612,19 @@ class DataNodeWriter(Resource):
         - api
       summary: Write into a data node.
       description: |
-        Write data from request body into a data node by *datanode_id*. If the data node does not exist, a 404 error is returned.
+        Write data from request body into a data node by *datanode_id*. If the data node does not exist, a 404 error is
+        returned.
 
         !!! Note
-          When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint requires `TAIPY_EDITOR` role.
+          When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint
+          requires `TAIPY_EDITOR` role.
 
         Code example:
 
         ```shell
-          curl -X PUT -d '[{"path": "/abc", "type": 1}, {"path": "/def", "type": 2}]' -H 'Content-Type: application/json'  http://localhost:5000/api/v1/datanodes/DATANODE_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9/write
+          curl -X PUT -d '[{"path": "/abc", "type": 1}, {"path": "/def", "type": 2}]' \\
+          -H 'Content-Type: application/json' \\
+           http://localhost:5000/api/v1/datanodes/DATANODE_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9/write
         ```
 
       parameters:

+ 1 - 1
src/taipy/rest/api/resources/scenario.py

@@ -460,7 +460,7 @@ class ScenarioExecutor(Resource):
 
             === "Curl"
                 ```shell
-                    curl -X POST http://localhost:5000/api/v1/scenarios/submit/SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c
+                    curl -X POST http://localhost:5000/api/v1/scenarios/submit/SCENARIO_658d-5834-4d73-84e4-a6343df5e08c
                 ```
                 In this example the REST API is served on port 5000 on localhost. We are using curl command line
                 client.

+ 5 - 3
src/taipy/rest/api/resources/sequence.py

@@ -163,7 +163,8 @@ class SequenceList(Resource):
         - api
       summary: Create a sequence.
       description: |
-        Create a sequence from scenario_id, sequence_name and task_ids. If the scenario_id does not exist or sequence_name is not provided, a 404 error is returned.
+        Create a sequence from scenario_id, sequence_name and task_ids. If the scenario_id does not exist or
+        sequence_name is not provided, a 404 error is returned.
         !!! Note
           When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint
           requires _TAIPY_EDITOR_ role.
@@ -171,7 +172,8 @@ class SequenceList(Resource):
         Code example:
 
         ```shell
-          curl -X POST --data '{"scenario_id": "SCENARIO_scenario_id", "sequence_name": "sequence", "tasks": []}' http://localhost:5000/api/v1/sequences
+          curl -X POST --data '{"scenario_id": "SCENARIO_scenario_id", "sequence_name": "sequence", "tasks": []}' \\
+           http://localhost:5000/api/v1/sequences
         ```
 
       parameters:
@@ -256,7 +258,7 @@ class SequenceExecutor(Resource):
         Code example:
 
         ```shell
-          curl -X POST http://localhost:5000/api/v1/sequences/submit/SEQUENCE_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9
+          curl -X POST http://localhost:5000/api/v1/sequences/submit/SEQUENCE_my_config_7575-4e09-4e00-958d-e352ee426cc9
         ```
 
       parameters:

+ 0 - 1
src/taipy/rest/api/schemas/task.py

@@ -13,7 +13,6 @@ from marshmallow import Schema, fields
 
 
 class TaskSchema(Schema):
-
     config_id = fields.String()
     id = fields.String()
     owner_id = fields.String()

+ 13 - 3
src/taipy/rest/commons/encoder.py

@@ -1,12 +1,22 @@
+# Copyright 2023 Avaiga Private Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations under the License.
+
 import json
-from typing import Any, Union
 from datetime import datetime
 from enum import Enum
-
-
+from typing import Any, Union
 
 Json = Union[dict, list, str, int, float, bool, None]
 
+
 class _CustomEncoder(json.JSONEncoder):
     def default(self, o: Any) -> Json:
         if isinstance(o, Enum):

+ 0 - 6
src/taipy/rest/extensions.py

@@ -14,13 +14,7 @@
 All extensions here are used as singletons and
 initialized in application factory
 """
-from flask_marshmallow import Marshmallow
-from flask_migrate import Migrate
-from passlib.context import CryptContext
 
 from .commons.apispec import APISpecExt
 
-ma = Marshmallow()
-migrate = Migrate()
 apispec = APISpecExt()
-pwd_context = CryptContext(schemes=["pbkdf2_sha256"], deprecated="auto")

+ 3 - 2
src/taipy/rest/rest.py

@@ -31,8 +31,9 @@ class Rest:
         However, editing these parameters is only recommended for advanced users. Indeed, the default behavior of the
         REST server without any required configuration satisfies all the standard and basic needs.
         """
-        self._app = _create_app(Config.global_config.testing or False, Config.global_config.env,
-                                Config.global_config.secret_key)
+        self._app = _create_app(
+            Config.global_config.testing or False, Config.global_config.env, Config.global_config.secret_key
+        )
 
     def run(self, **kwargs):
         """

+ 2 - 4
src/taipy/rest/setup.py

@@ -49,11 +49,9 @@ setup(
     install_requires=[
         "flask>=3.0.0,<3.1",
         "flask-restful>=0.3.9,<0.4",
-        "flask-migrate>=3.1,<4.0",
-        "flask-marshmallow>=0.14,<0.15",
-        "marshmallow-sqlalchemy>=0.25,<0.29",
         "passlib>=1.7.4,<1.8",
-        "apispec[yaml]>=5.1,<6.0",
+        "marshmallow>=3.20.1,<3.30",
+        "apispec[yaml]>=6.3,<7.0",
         "apispec-webframeworks>=0.5.2,<0.6",
         "taipy-core@git+https://git@github.com/Avaiga/taipy-core.git@develop",
     ],