Determine the load order of referenced projects in a Matlab project

10 vues (au cours des 30 derniers jours)
William Stokes
William Stokes le 5 Avr 2023
Commenté : William Stokes le 18 Avr 2023
Is it possible to determine the order in which referenced projects are loaded in a Matlab project? There seems no obvious way to do it.
It is not possible to "drag" the order in the UI, and the order in the proj.ProjectReferences() does not appear to be respected when loading the project?
Is it possible?
  2 commentaires
Anurag Ojha
Anurag Ojha le 13 Avr 2023
Hi william,
Can you provide more information what exactly are you looking for, by load order do you mean in the order projects are loaded in MATLAB project?
William Stokes
William Stokes le 13 Avr 2023
Hello.
Yes, that is exactly what I mean.
Within our Matlab project we have two referenced projects. Ideally what I would like is for these projects to load in a specific order, so that the startup code of Project A runs before Project B. Currently there doesn't appear to be any way to explicitly specify that I want Project A startup to run first. I have tried
  • Removing both references and adding them back in, Project A first, then B.
  • The same as above but adding Project B first.
  • It does not appear to be alphabetical (the projects are not really named "Project A" and "Project B", and I observe the first one alphabetically does not load first).
  • I've tried getting the project object currentProject().ProjectReferences and modifying the order of the projects in this array, but this doesn't do it.
I appreciate that projects startup code should be independent and so it should probably not matter which order they load. That is true, but in this specific case, we have Project A creating a Python environment with pyenv which should happen first. The startup code for Project B requires some Python packages to be installed into an existing python environment if one is loaded, otherwise Project B will create its own environment. In this specific case, we want to ensure that Project A loads first, so that it creates the python environment, into which Project B can install the required packages.
I assumed that specifiying the loading order would be possible, but I cannot seem to find any obvious way to do it. Any help you can offer would be appreciated. Many thanks.

Connectez-vous pour commenter.

Réponses (1)

Anurag Ojha
Anurag Ojha le 14 Avr 2023
Hi William,
As per my understanding you want to know if it is explicitly possible to set the order in which projects are loaded in MATLAB Project. In Matlab project we use matlab.project.loadProject(projectPath) to load the project which loads the project specified by the file or folder projectPath. If any projects are currently open, MATLAB closes them before loading the specified project. There isn’t any way to explicitly determine the order in which projects are loaded.
To explore more, you can refer to the following MATLAB Documentations
Hope it helps!!

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by