|
@@ -10,6 +10,7 @@
|
|
# specific language governing permissions and limitations under the License.
|
|
# specific language governing permissions and limitations under the License.
|
|
|
|
|
|
import json
|
|
import json
|
|
|
|
+from importlib.metadata import version
|
|
from typing import Dict, List, Optional, Tuple
|
|
from typing import Dict, List, Optional, Tuple
|
|
|
|
|
|
from taipy.logger._taipy_logger import _TaipyLogger
|
|
from taipy.logger._taipy_logger import _TaipyLogger
|
|
@@ -20,10 +21,22 @@ __logger = _TaipyLogger._get_logger()
|
|
def __update_parent_ids(entity: Dict, data: Dict) -> Dict:
|
|
def __update_parent_ids(entity: Dict, data: Dict) -> Dict:
|
|
# parent_ids was not present in 2.0, need to be search for in tasks
|
|
# parent_ids was not present in 2.0, need to be search for in tasks
|
|
parent_ids = entity.get("parent_ids", [])
|
|
parent_ids = entity.get("parent_ids", [])
|
|
|
|
+ id = entity["id"]
|
|
|
|
+
|
|
if not parent_ids:
|
|
if not parent_ids:
|
|
parent_ids = __search_parent_ids(entity["id"], data)
|
|
parent_ids = __search_parent_ids(entity["id"], data)
|
|
entity["parent_ids"] = parent_ids
|
|
entity["parent_ids"] = parent_ids
|
|
|
|
|
|
|
|
+ if "TASK" in id:
|
|
|
|
+ parents = []
|
|
|
|
+ for parent in entity.get("parent_ids", []):
|
|
|
|
+ if "PIPELINE" in parent:
|
|
|
|
+ continue
|
|
|
|
+ parents.append(parent)
|
|
|
|
+ if entity.get("owner_id") and entity.get("owner_id") not in parents:
|
|
|
|
+ parents.append(entity.get("owner_id"))
|
|
|
|
+ entity["parent_ids"] = parents
|
|
|
|
+
|
|
return entity
|
|
return entity
|
|
|
|
|
|
|
|
|
|
@@ -91,14 +104,15 @@ def __migrate_subscriber(fct_module, fct_name):
|
|
|
|
|
|
|
|
|
|
def __migrate_scenario(scenario: Dict, data: Dict) -> Dict:
|
|
def __migrate_scenario(scenario: Dict, data: Dict) -> Dict:
|
|
- # pipelines were replaced by tasks
|
|
|
|
- scenario["tasks"] = __fetch_tasks_from_pipelines(scenario["pipelines"], data)
|
|
|
|
|
|
+ if "pipelines" in scenario:
|
|
|
|
+ # pipelines were replaced by tasks
|
|
|
|
+ scenario["tasks"] = scenario.get("tasks") or __fetch_tasks_from_pipelines(scenario["pipelines"], data)
|
|
|
|
|
|
- # pipeline attribute not removed in 3.0
|
|
|
|
- scenario["pipelines"] = None
|
|
|
|
|
|
+ # pipeline attribute not removed in 3.0
|
|
|
|
+ scenario["pipelines"] = None
|
|
|
|
|
|
# additional_data_nodes attribute added
|
|
# additional_data_nodes attribute added
|
|
- scenario["additional_data_nodes"] = []
|
|
|
|
|
|
+ scenario["additional_data_nodes"] = scenario.get("additional_data_nodes", [])
|
|
|
|
|
|
return scenario
|
|
return scenario
|
|
|
|
|
|
@@ -122,12 +136,12 @@ def __migrate_task(task: Dict, data: Dict, is_entity: bool = True) -> Dict:
|
|
if is_entity:
|
|
if is_entity:
|
|
# parent_id has been renamed to owner_id
|
|
# parent_id has been renamed to owner_id
|
|
try:
|
|
try:
|
|
- task["owner_id"] = task["parent_id"]
|
|
|
|
|
|
+ task["owner_id"] = task.get("owner_id", task["parent_id"])
|
|
del task["parent_id"]
|
|
del task["parent_id"]
|
|
except KeyError:
|
|
except KeyError:
|
|
pass
|
|
pass
|
|
|
|
|
|
- # properties was not present in 2.0
|
|
|
|
|
|
+ # properties attribute was not present in 2.0
|
|
task["properties"] = task.get("properties", {})
|
|
task["properties"] = task.get("properties", {})
|
|
|
|
|
|
# skippable was not present in 2.0
|
|
# skippable was not present in 2.0
|
|
@@ -182,7 +196,7 @@ def __migrate_datanode(datanode: Dict) -> Dict:
|
|
|
|
|
|
# parent_id has been renamed to owner_id
|
|
# parent_id has been renamed to owner_id
|
|
try:
|
|
try:
|
|
- datanode["owner_id"] = datanode["parent_id"]
|
|
|
|
|
|
+ datanode["owner_id"] = datanode.get("owner_id", datanode["parent_id"])
|
|
del datanode["parent_id"]
|
|
del datanode["parent_id"]
|
|
except KeyError:
|
|
except KeyError:
|
|
pass
|
|
pass
|
|
@@ -241,6 +255,9 @@ def __migrate_global_config(config: Dict):
|
|
except KeyError:
|
|
except KeyError:
|
|
pass
|
|
pass
|
|
|
|
|
|
|
|
+ if "core_version" not in config["CORE"] or config["CORE"]["core_version"] != version("taipy-core"):
|
|
|
|
+ config["CORE"]["core_version"] = version("taipy-core")
|
|
|
|
+
|
|
return config
|
|
return config
|
|
|
|
|
|
|
|
|
|
@@ -255,14 +272,16 @@ def __migrate_version(version: Dict) -> Dict:
|
|
config = __migrate_global_config(config)
|
|
config = __migrate_global_config(config)
|
|
|
|
|
|
# replace pipelines for tasks
|
|
# replace pipelines for tasks
|
|
- pipelines_section = config["PIPELINE"]
|
|
|
|
- for id, content in config["SCENARIO"].items():
|
|
|
|
- tasks = []
|
|
|
|
- for _pipeline in content["pipelines"]:
|
|
|
|
- pipeline_id = _pipeline.split(":")[0]
|
|
|
|
- tasks = pipelines_section[pipeline_id]["tasks"]
|
|
|
|
- config["SCENARIO"][id]["tasks"] = tasks
|
|
|
|
- del config["SCENARIO"][id]["pipelines"]
|
|
|
|
|
|
+ if "PIPELINE" in config:
|
|
|
|
+ pipelines_section = config["PIPELINE"]
|
|
|
|
+ for id, content in config["SCENARIO"].items():
|
|
|
|
+ tasks = []
|
|
|
|
+ for _pipeline in content["pipelines"]:
|
|
|
|
+ pipeline_id = _pipeline.split(":")[0]
|
|
|
|
+ tasks = pipelines_section[pipeline_id]["tasks"]
|
|
|
|
+ config["SCENARIO"][id]["tasks"] = tasks
|
|
|
|
+ del config["SCENARIO"][id]["pipelines"]
|
|
|
|
+ del config["PIPELINE"]
|
|
|
|
|
|
for id, content in config["TASK"].items():
|
|
for id, content in config["TASK"].items():
|
|
config["TASK"][id] = __migrate_task_config(content, config)
|
|
config["TASK"][id] = __migrate_task_config(content, config)
|
|
@@ -270,8 +289,6 @@ def __migrate_version(version: Dict) -> Dict:
|
|
for id, content in config["DATA_NODE"].items():
|
|
for id, content in config["DATA_NODE"].items():
|
|
config["DATA_NODE"][id] = __migrate_datanode_config(content)
|
|
config["DATA_NODE"][id] = __migrate_datanode_config(content)
|
|
|
|
|
|
- del config["PIPELINE"]
|
|
|
|
-
|
|
|
|
version["config"] = json.dumps(config, ensure_ascii=False, indent=0)
|
|
version["config"] = json.dumps(config, ensure_ascii=False, indent=0)
|
|
return version
|
|
return version
|
|
|
|
|