diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0e26cdb001..2b8c6b4ae5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -81,7 +81,7 @@ jobs: continue-on-error: true shell: bash run: | - yq '.services.fixworker.environment += "FIXWORKER_OVERRIDE=fixworker.collector=example"' docker-compose.yaml > docker-compose-model-gen.yaml + yq '.services.fixcore.environment += "FIXCORE_MODEL_FROM_PLUGINS=true"' docker-compose.yaml > docker-compose-model-gen.yaml PSK= FIXCORE_ANALYTICS_OPT_OUT=true docker-compose -f docker-compose-model-gen.yaml up -d cd ${{ github.workspace }}/docs.fix.security/docs/resources python3 ${{ github.workspace }}/docs.fix.security/tools/export_models.py @@ -345,7 +345,7 @@ jobs: continue-on-error: true shell: bash run: | - yq '.services.fixworker.environment += "FIXWORKER_OVERRIDE=fixworker.collector=example"' docker-compose.yaml > docker-compose-model-gen.yaml + yq '.services.fixcore.environment += "FIXCORE_MODEL_FROM_PLUGINS=true"' docker-compose.yaml > docker-compose-model-gen.yaml PSK= FIXCORE_ANALYTICS_OPT_OUT=true docker-compose -f docker-compose-model-gen.yaml up -d cd ${{ github.workspace }}/inventory.fix.security/versioned_docs/version-${{ steps.release.outputs.docsVersion }}/reference/unified-data-model python3 ${{ github.workspace }}/inventory.fix.security/tools/export_models.py diff --git a/fixcore/fixcore/__main__.py b/fixcore/fixcore/__main__.py index 872f4acc3d..ede3e62b59 100644 --- a/fixcore/fixcore/__main__.py +++ b/fixcore/fixcore/__main__.py @@ -174,7 +174,8 @@ async def direct_tenant(deps: TenantDependencies) -> None: deps.add(ServiceNames.system_data, db_change.current) message_bus = deps.add(ServiceNames.message_bus, MessageBus()) scheduler = deps.add(ServiceNames.scheduler, APScheduler() if not config.args.no_scheduling else NoScheduler()) - model = deps.add(ServiceNames.model_handler, ModelHandlerDB(db, config.runtime.plantuml_server)) + model_handler_class = ModelHandlerFromCodeAndDB if config.args.model_from_plugins else ModelHandlerDB + model = deps.add(ServiceNames.model_handler, model_handler_class(db, config.runtime.plantuml_server)) worker_task_queue = deps.add(ServiceNames.worker_task_queue, WorkerTaskQueue()) # a "real" config override deps.add, unlike the one used for core config config_override_service = deps.add( diff --git a/fixcore/fixcore/system_start.py b/fixcore/fixcore/system_start.py index 02cc292a6a..479e32b66a 100644 --- a/fixcore/fixcore/system_start.py +++ b/fixcore/fixcore/system_start.py @@ -229,6 +229,8 @@ def key_value(kv: str) -> Tuple[str, JsonElement]: choices=AllowedRoleNames, help="Assign this role to the service. Only takes effect when no PSK / UserManagement is used.", ) + # only valid in non-multi-tenant setup: generate model from plugins, instead of loading it from the database + parser.add_argument("--model-from-plugins", default=False, action="store_true", help=argparse.SUPPRESS) parsed: Namespace = parser.parse_args(args if args else []) diff --git a/fixlib/fixlib/core/model_export.py b/fixlib/fixlib/core/model_export.py index 8d86066b69..2f6821c9f5 100644 --- a/fixlib/fixlib/core/model_export.py +++ b/fixlib/fixlib/core/model_export.py @@ -265,16 +265,11 @@ def export_data_class(clazz: type) -> None: metadata["service"] = s if (slc := getattr(clazz, "categories", None)) and callable(slc) and (sl := slc()): metadata["categories"] = sl - if (docs_url := getattr(clazz, "_docs_url", None)) and isinstance(docs_url, str): - metadata["docs_url"] = docs_url - if ( # only export kind description on aggregate roots - with_kind_description - and (ar := aggregate_root) - and issubclass(clazz, ar) - and (s := clazz.__dict__.get("_kind_description", None)) - and isinstance(s, str) - ): - metadata["description"] = s + if with_kind_description and (ar := aggregate_root) and issubclass(clazz, ar): + if (s := clazz.__dict__.get("_kind_description", None)) and isinstance(s, str): + metadata["description"] = s + if (docs_url := getattr(clazz, "_docs_url", None)) and isinstance(docs_url, str): + metadata["docs_url"] = docs_url if root and (source := model_source(clazz.__module__)): metadata["source"] = source