cornflow 1.2.3a5__py3-none-any.whl → 1.3.0rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. cornflow/app.py +24 -8
  2. cornflow/cli/service.py +93 -43
  3. cornflow/commands/auxiliar.py +4 -1
  4. cornflow/commands/dag.py +7 -7
  5. cornflow/commands/permissions.py +13 -7
  6. cornflow/commands/views.py +3 -0
  7. cornflow/config.py +26 -6
  8. cornflow/endpoints/__init__.py +27 -0
  9. cornflow/endpoints/case.py +37 -21
  10. cornflow/endpoints/dag.py +5 -5
  11. cornflow/endpoints/data_check.py +8 -7
  12. cornflow/endpoints/example_data.py +4 -2
  13. cornflow/endpoints/execution.py +215 -127
  14. cornflow/endpoints/health.py +30 -11
  15. cornflow/endpoints/instance.py +3 -3
  16. cornflow/endpoints/login.py +9 -2
  17. cornflow/endpoints/permission.py +1 -2
  18. cornflow/endpoints/schemas.py +3 -3
  19. cornflow/endpoints/signup.py +17 -11
  20. cornflow/migrations/versions/999b98e24225.py +34 -0
  21. cornflow/migrations/versions/cef1df240b27_.py +34 -0
  22. cornflow/models/__init__.py +2 -1
  23. cornflow/models/dag.py +8 -9
  24. cornflow/models/dag_permissions.py +3 -3
  25. cornflow/models/execution.py +2 -3
  26. cornflow/models/permissions.py +1 -0
  27. cornflow/models/user.py +1 -1
  28. cornflow/schemas/execution.py +14 -1
  29. cornflow/schemas/health.py +1 -1
  30. cornflow/shared/authentication/auth.py +14 -1
  31. cornflow/shared/authentication/decorators.py +32 -2
  32. cornflow/shared/const.py +58 -1
  33. cornflow/shared/exceptions.py +2 -1
  34. cornflow/tests/base_test_execution.py +798 -0
  35. cornflow/tests/const.py +1 -0
  36. cornflow/tests/integration/test_commands.py +2 -2
  37. cornflow/tests/integration/test_cornflowclient.py +2 -1
  38. cornflow/tests/unit/test_apiview.py +7 -1
  39. cornflow/tests/unit/test_cases.py +1 -1
  40. cornflow/tests/unit/test_cli.py +6 -3
  41. cornflow/tests/unit/test_commands.py +7 -6
  42. cornflow/tests/unit/test_dags.py +3 -3
  43. cornflow/tests/unit/test_example_data.py +1 -1
  44. cornflow/tests/unit/test_executions.py +115 -535
  45. cornflow/tests/unit/test_get_resources.py +103 -0
  46. cornflow/tests/unit/test_health.py +84 -3
  47. cornflow/tests/unit/test_main_alarms.py +1 -1
  48. cornflow/tests/unit/test_roles.py +2 -1
  49. cornflow/tests/unit/test_schema_from_models.py +1 -1
  50. cornflow/tests/unit/test_schemas.py +1 -1
  51. cornflow/tests/unit/test_sign_up.py +181 -6
  52. cornflow/tests/unit/tools.py +93 -10
  53. {cornflow-1.2.3a5.dist-info → cornflow-1.3.0rc1.dist-info}/METADATA +3 -3
  54. {cornflow-1.2.3a5.dist-info → cornflow-1.3.0rc1.dist-info}/RECORD +57 -53
  55. {cornflow-1.2.3a5.dist-info → cornflow-1.3.0rc1.dist-info}/WHEEL +0 -0
  56. {cornflow-1.2.3a5.dist-info → cornflow-1.3.0rc1.dist-info}/entry_points.txt +0 -0
  57. {cornflow-1.2.3a5.dist-info → cornflow-1.3.0rc1.dist-info}/top_level.txt +0 -0
cornflow/tests/const.py CHANGED
@@ -15,6 +15,7 @@ INSTANCE_URL = PREFIX + "/instance/"
15
15
  INSTANCE_MPS = _get_file("./data/test_mps.mps")
16
16
  INSTANCE_GC_20 = _get_file("./data/gc_20_7.json")
17
17
  INSTANCE_FILE_FAIL = _get_file("./unit/test_instances.py")
18
+ EDIT_EXECUTION_SOLUTION = _get_file("./data/edit_execution_solution.json")
18
19
 
19
20
  EXECUTION_PATH = _get_file("./data/new_execution.json")
20
21
  CUSTOM_CONFIG_PATH = _get_file("./data/new_execution_custom_config.json")
@@ -1,7 +1,7 @@
1
1
  from flask import current_app
2
2
 
3
3
  from cornflow.commands.dag import register_deployed_dags_command
4
- from cornflow.models import DeployedDAG
4
+ from cornflow.models import DeployedWorkflow
5
5
  from cornflow.tests.const import PUBLIC_DAGS
6
6
  from cornflow.tests.custom_liveServer import CustomTestCaseLive
7
7
 
@@ -15,7 +15,7 @@ class TestCornflowCommands(CustomTestCaseLive):
15
15
  register_deployed_dags_command(
16
16
  config["AIRFLOW_URL"], config["AIRFLOW_USER"], config["AIRFLOW_PWD"], False
17
17
  )
18
- dags = DeployedDAG.get_all_objects()
18
+ dags = DeployedWorkflow.get_all_objects()
19
19
 
20
20
  for dag in PUBLIC_DAGS:
21
21
  self.assertIn(dag, [d.id for d in dags])
@@ -1,6 +1,7 @@
1
1
  """
2
2
 
3
3
  """
4
+
4
5
  # Full imports
5
6
  import json
6
7
  import pulp
@@ -279,7 +280,7 @@ class TestCornflowClientOpen(TestCornflowClientBasic):
279
280
  def test_server_alive(self):
280
281
  data = self.client.is_alive()
281
282
  cf_status = data["cornflow_status"]
282
- af_status = data["airflow_status"]
283
+ af_status = data["backend_status"]
283
284
  self.assertEqual(str, type(cf_status))
284
285
  self.assertEqual(str, type(af_status))
285
286
  self.assertEqual(cf_status, STATUS_HEALTHY)
@@ -13,7 +13,7 @@ TestApiViewListEndpoint
13
13
  """
14
14
 
15
15
  # Import from internal modules
16
- from cornflow.endpoints import ApiViewListEndpoint, resources, alarms_resources
16
+ from cornflow.endpoints import ApiViewListEndpoint, alarms_resources, get_resources
17
17
  from cornflow.models import ViewModel
18
18
  from cornflow.shared.const import ROLES_MAP
19
19
  from cornflow.tests.const import APIVIEW_URL
@@ -42,6 +42,8 @@ class TestApiViewListEndpoint(CustomTestCase):
42
42
  """
43
43
  super().setUp()
44
44
  self.roles_with_access = ApiViewListEndpoint.ROLES_WITH_ACCESS
45
+ # Get resources within application context
46
+ resources = get_resources()
45
47
  self.payload = [
46
48
  {
47
49
  "name": view["endpoint"],
@@ -127,6 +129,8 @@ class TestApiViewModel(CustomTestCase):
127
129
  """
128
130
  super().setUp()
129
131
  self.roles_with_access = ApiViewListEndpoint.ROLES_WITH_ACCESS
132
+ # Get resources within application context
133
+ resources = get_resources()
130
134
  self.payload = [
131
135
  {
132
136
  "name": view["endpoint"],
@@ -141,6 +145,8 @@ class TestApiViewModel(CustomTestCase):
141
145
  """
142
146
  Test that the get_all_objects method works properly
143
147
  """
148
+ # Get resources within application context
149
+ resources = get_resources()
144
150
  expected_count = len(resources) + len(alarms_resources)
145
151
  # Test getting all objects
146
152
  all_instances = ViewModel.get_all_objects().all()
@@ -41,7 +41,7 @@ import zlib
41
41
 
42
42
 
43
43
  # Import from internal modules
44
- from cornflow.models import CaseModel, ExecutionModel, InstanceModel, UserModel
44
+ from cornflow.models import CaseModel, ExecutionModel, InstanceModel
45
45
  from cornflow.shared.const import DATA_DOES_NOT_EXIST_MSG
46
46
  from cornflow.shared.utils import hash_json_256
47
47
  from cornflow.tests.const import (
@@ -33,7 +33,7 @@ from cornflow.models import (
33
33
  from cornflow.models import UserModel
34
34
  from cornflow.shared import db
35
35
  from cornflow.shared.exceptions import NoPermission, ObjectDoesNotExist
36
- from cornflow.endpoints import resources, alarms_resources
36
+ from cornflow.endpoints import alarms_resources, get_resources
37
37
 
38
38
 
39
39
  class CLITests(TestCase):
@@ -278,6 +278,7 @@ class CLITests(TestCase):
278
278
  - Correct number of views created
279
279
  - Database state after initialization
280
280
  """
281
+ resources = get_resources()
281
282
  runner = CliRunner()
282
283
  result = runner.invoke(cli, ["views", "init", "-v"])
283
284
  self.assertEqual(result.exit_code, 0)
@@ -315,6 +316,7 @@ class CLITests(TestCase):
315
316
  - Correct number of actions, roles, views, and permissions
316
317
  - Database state after initialization
317
318
  """
319
+ resources = get_resources()
318
320
  runner = CliRunner()
319
321
  result = runner.invoke(cli, ["permissions", "init", "-v"])
320
322
  self.assertEqual(result.exit_code, 0)
@@ -325,7 +327,7 @@ class CLITests(TestCase):
325
327
  self.assertEqual(len(actions), 5)
326
328
  self.assertEqual(len(roles), 4)
327
329
  self.assertEqual(len(views), (len(resources) + len(alarms_resources)))
328
- self.assertEqual(len(permissions), 562)
330
+ self.assertEqual(len(permissions), 583)
329
331
 
330
332
  def test_permissions_base_command(self):
331
333
  """
@@ -337,6 +339,7 @@ class CLITests(TestCase):
337
339
  - Correct setup of all permission components
338
340
  - Database state consistency
339
341
  """
342
+ resources = get_resources()
340
343
  runner = CliRunner()
341
344
  runner.invoke(cli, ["actions", "init", "-v"])
342
345
  runner.invoke(cli, ["roles", "init", "-v"])
@@ -350,7 +353,7 @@ class CLITests(TestCase):
350
353
  self.assertEqual(len(actions), 5)
351
354
  self.assertEqual(len(roles), 4)
352
355
  self.assertEqual(len(views), (len(resources) + len(alarms_resources)))
353
- self.assertEqual(len(permissions), 562)
356
+ self.assertEqual(len(permissions), 583)
354
357
 
355
358
  def test_service_entrypoint(self):
356
359
  """
@@ -31,7 +31,7 @@ from cornflow.app import (
31
31
  register_views,
32
32
  )
33
33
  from cornflow.commands.dag import register_deployed_dags_command_test
34
- from cornflow.endpoints import resources, alarms_resources
34
+ from cornflow.endpoints import alarms_resources, get_resources
35
35
  from cornflow.models import (
36
36
  ActionModel,
37
37
  PermissionViewRoleModel,
@@ -39,7 +39,7 @@ from cornflow.models import (
39
39
  ViewModel,
40
40
  )
41
41
  from cornflow.models import (
42
- DeployedDAG,
42
+ DeployedWorkflow,
43
43
  PermissionsDAG,
44
44
  UserModel,
45
45
  )
@@ -98,6 +98,7 @@ class TestCommands(TestCase):
98
98
  "email": "testemail@test.org",
99
99
  "password": "Testpassword1!",
100
100
  }
101
+ resources = get_resources()
101
102
  self.resources = resources + alarms_resources
102
103
  self.runner = self.create_app().test_cli_runner()
103
104
  self.runner.invoke(register_roles, ["-v"])
@@ -356,7 +357,7 @@ class TestCommands(TestCase):
356
357
  - Presence of required DAGs
357
358
  """
358
359
  register_deployed_dags_command_test(verbose=True)
359
- dags = DeployedDAG.get_all_objects()
360
+ dags = DeployedWorkflow.get_all_objects()
360
361
  for dag in ["solve_model_dag", "gc", "timer"]:
361
362
  self.assertIn(dag, [d.id for d in dags])
362
363
 
@@ -381,8 +382,8 @@ class TestCommands(TestCase):
381
382
  service_permissions = PermissionsDAG.get_user_dag_permissions(service.id)
382
383
  admin_permissions = PermissionsDAG.get_user_dag_permissions(admin.id)
383
384
 
384
- self.assertEqual(3, len(service_permissions))
385
- self.assertEqual(3, len(admin_permissions))
385
+ self.assertEqual(4, len(service_permissions))
386
+ self.assertEqual(4, len(admin_permissions))
386
387
 
387
388
  def test_dag_permissions_command_no_open(self):
388
389
  """
@@ -405,7 +406,7 @@ class TestCommands(TestCase):
405
406
  service_permissions = PermissionsDAG.get_user_dag_permissions(service.id)
406
407
  admin_permissions = PermissionsDAG.get_user_dag_permissions(admin.id)
407
408
 
408
- self.assertEqual(3, len(service_permissions))
409
+ self.assertEqual(4, len(service_permissions))
409
410
  self.assertEqual(0, len(admin_permissions))
410
411
 
411
412
  def test_argument_parsing_correct(self):
@@ -24,7 +24,7 @@ from cornflow.commands.access import access_init_command
24
24
  from cornflow.commands.dag import register_deployed_dags_command_test
25
25
  from cornflow.commands.permissions import register_dag_permissions_command
26
26
  from cornflow.shared.const import ADMIN_ROLE, SERVICE_ROLE
27
- from cornflow.models import DeployedDAG, PermissionsDAG, UserModel, UserRoleModel
27
+ from cornflow.models import DeployedWorkflow, PermissionsDAG, UserModel, UserRoleModel
28
28
  from cornflow.shared.const import EXEC_STATE_CORRECT, EXEC_STATE_MANUAL
29
29
  from cornflow.shared import db
30
30
  from cornflow.tests.const import (
@@ -38,7 +38,7 @@ from cornflow.tests.const import (
38
38
  USER_URL,
39
39
  EXECUTION_URL,
40
40
  )
41
- from cornflow.tests.unit.test_executions import TestExecutionsDetailEndpointMock
41
+ from cornflow.tests.base_test_execution import TestExecutionsDetailEndpointMock
42
42
  from cornflow_client import get_pulp_jsonschema, get_empty_schema
43
43
 
44
44
 
@@ -350,7 +350,7 @@ class TestDeployedDAG(TestCase):
350
350
  """
351
351
  before = PermissionsDAG.get_user_dag_permissions(self.admin["id"])
352
352
  self.assertIsNotNone(before)
353
- dag = DeployedDAG.query.get("solve_model_dag")
353
+ dag = DeployedWorkflow.query.get("solve_model_dag")
354
354
  dag.delete()
355
355
  after = PermissionsDAG.get_user_dag_permissions(self.admin["id"])
356
356
  self.assertNotEqual(before, after)
@@ -35,7 +35,7 @@ class TestExampleDataEndpoint(CustomTestCase):
35
35
  def patch_af_client(self, Airflow_mock):
36
36
  af_client = Airflow_mock.return_value
37
37
  af_client.is_alive.return_value = True
38
- af_client.get_dag_info.return_value = {}
38
+ af_client.get_workflow_info.return_value = {}
39
39
  af_client.get_one_variable.return_value = {
40
40
  "value": json.dumps(self.example),
41
41
  "key": self.schema_name,