Cube Compilation Order in UCR: How to Manage Dependencies?
Hello all,
We are currently developing a set of cubes in Unified Care Report (UCR) for data analysis purposes. However, we are encountering issues with cube dependencies, where certain cubes rely on others to be compiled beforehand. The complexity of these dependencies is becoming increasingly difficult to manage, particularly when attempting to deploy the cubes.
The problem arises when trying to compile a cube that depends on another cube, which may also have its own dependencies. For instance, when compiling the Test.Cube.EncounterHealthPlans cube, we receive the following error:
Compiling class Test.Cube.EncounterHealthPlans ERROR #5001: Related cube must be compiled before this cube: 'Encounters' ERROR #5490: Error running generator for method '%GetModel:Test.Cube.EncounterHealthPlans' ERROR: %DeepSee.CubeDefinition.cls(%GetModel) of generated code compiling subclass 'Test.Cube.EncounterHealthPlans' ERROR #5030: An error occurred while compiling class 'Test.Cube.EncounterHealthPlans'
To resolve this issue, we are forced to manually compile the dependent cube (Encounters), which may itself have dependencies. We have reviewed the documentation but were unable to find a method or API that provides the correct compilation order for the cubes.
Has anyone else encountered this issue and found a solution? We are looking for a way to programmatically determine the correct compilation order for our cubes, potentially using the $System.OBJ.Compile() method or an alternative approach.
Any guidance or recommendations would be greatly appreciated.
Best regards,
Comments
I suggest to add to your classes DependsOn or CompileAfter Class keywords.
Hi Enrico,
Thanks for your answer. This would mean me taking care of the dependencies, and as the cubes are actually dependant because of relationships I expect any intersystems tool to either compile the class managing the dependencies, or to compile (not build) a cube.
@David.Satorres6134 , you asked:
We have reviewed the documentation but were unable to find a method or API that provides the correct compilation order for the cubes.
I gave the documentation links on how to provide the correct compilation order for classes.
In most cases the compiler does take care of dependencies and build/compile in correct order.
In my experience I have very, very rarely (maybe a couple of times) used DependsOn or CompileAfter Class keywords (I don't do cubes/DeepSee).
I'm not familiar with multiple cubes compilation, but evidently your implementation has some particular dependency that the compiler is unable to identify and take care of it.
Maybe (just guessing here) you have some cross dependency that is "resolved" with multiple compilations?
Looking at the documentation, i found this Cube dependencies building
Essentially you need to define the dependencies of the cubes using the DependsOn (not the same as the Class keyword) keyword in Designer. And you need to define the build order by creating either a Utility class with a BuildMethod or by using CubeManager.
That's it, thanks Timo!
Using ##class(%DeepSee.CubeManager.Utils).GetCubeGroups(.groupsList) I can get a list of cubes and the order to build, and then I get the class from ^DeepSee.Cubes("cubes"). Once everything sorted, only need to launch $System.OBJ.Compile() for each class.