gama-platform / gama-platform.github.io

Repository for the website of GAMA
https://gama-platform.github.io/
GNU General Public License v3.0
4 stars 2 forks source link

Improve file paths' documentation #137

Closed ScriBanana closed 1 year ago

ScriBanana commented 1 year ago

Hi,

Describe the bug Importing a GAML file with an experiment makes it so you can run it from the both its definition and importing file. (Example : If I define an experiment "Run" in Experiment.gaml and use import "Experiment.gaml" in another file, I will have the image button over both in the UI.) The issue is that any relative path called in the model will depend on the file the button is pressed from.

To Reproduce Build a file system like this :

├── Models
│   ├── Experiments
│   │   └── Experiment.gaml
│   └── Main.gaml
└── Utilities
    └── GenerateExportFiles.gaml

with main.gaml :

model Main
import "../Utilities/GenerateExportFiles.gaml"
import "Experiments/Experiments.gaml"

Experiment.gaml :

model Experiments
import "../Main.gaml"
experiment run;

GenerateExportFiles.gaml :

model GenerateExportFiles
global {
    string outputDirectory <- "../OutputFiles/";
    init {
        save "I am data!" to: outputDirectory + "Data.csv" type: csv rewrite: true;
    }
}

Here's the result after running the experiment both from Main.gaml and Experiment.gaml :

├── models
│   ├── Experiments
│   │   └── Experiments.gaml
│   ├── Main.gaml
│   └── OutputFiles
│       └── Data.csv
├── OutputFiles
│   └── Data.csv
└── Utilities
    └── GenerateExportFiles.gaml

Expected behavior The OutputFiles directory being only created at the root of the project, at the location the path relative to where the save function was called from :

├── models
│   ├── Experiments
│   │   └── Experiments.gaml
│   └── Main.gaml
├── OutputFiles
│   └── Data.csv
└── Utilities
    └── GenerateExportFiles.gaml

Desktop (please complete the following information):

I could simply not cross-import gaml files as a workaround, but it still looks like an issue.

AlexisDrogoul commented 1 year ago

Actually, this organisation is more a feature than an issue, although I can understand why it might generate difficulties. It has been done so that support files and experiments could easily be defined together (so if you have relative paths in your model to access support files, the ones defined with the current experiment will be used).

ScriBanana commented 1 year ago

Hi Alexis, Alright, I see that being useful in that use case. It makes sense when explained. Maybe it deserves an explanation in the documentation to avoid confusion like mine ?

AlexisDrogoul commented 1 year ago

You are right. It definitely deserves a more detailed explanation somewhere... Let us ask @RoiArthurB where it could go in the documentation 🤔 ...

ScriBanana commented 1 year ago

I would suggest (if I may) at least a mention in https://gama-platform.org/wiki/DefiningExportFiles#facets, since it is the first time a newcomer would encounter using a path when reading the documentation.

RoiArthurB commented 1 year ago

Hi @ScriBanana

Sorry for the delayed answered (didn't saw the notification on this issue). Actually the documentation already explained this behavior here : https://gama-platform.org/wiki/ModelOrganization

But I agree that this little part is a bit difficult to spot. I'll add a part title so it can be catched by the search engine as well as a reminder at the location you pointed (as I guess you're a new comer with this software, I'll follow your logic for finding informations ;) )

I'll just ping @lesquoyb to know if you have some other enhancement idea about this point on the documentation :)


EDIT: Just to be clear, this relative path issue only exists within the GAML code; i.e. It doesn't happen with nested gaml file import (on the top of the file).

lesquoyb commented 1 year ago

Not sure about the documentation, but it could be nice to have a few statements to get the current file's path, the experiment file's path, directories and maybe others, so users can compose paths relative to what they think makes more sense. Like:

string embedded_file_path <- current_file_directory + "../includes/framework_file.png";
string custom_file_path <- experiment_file_directory + "../includes/my_file,png"
hqnghi88 commented 1 year ago

@lesquoyb we already have project_path or experiment.project_path

ScriBanana commented 1 year ago

Hi @RoiArthurB, hi all,

Thanks, although I am very unsure that the documentation makes things clear enough as of yet, to be honest.

Let me reformulate what I understood :

So two things I failed to understand, that had me confused :

So yes, maybe a section dedicated to what happens in what order when an execution is launched would make things clearer. Possibly as a complement to https://gama-platform.org/wiki/next/RuntimeConcepts ?

Either way, thanks for the clarification, it appears clear to me now.

RoiArthurB commented 1 year ago

A short explanation of this behavior has been added on the page https://github.com/gama-platform/gama/wiki/ModelOrganization as a note while describing how to import files, as well as in https://github.com/gama-platform/gama/wiki/DefiningExportFiles as a reminder while saving data with relative paths.

So yes, maybe a section dedicated to what happens in what order when an execution is launched would make things clearer. Possibly as a complement to https://gama-platform.org/wiki/next/RuntimeConcepts ?

I would disagree to add this point on this page as it's an overview of the main steps for creating a simulation and the scheduling of agents inside. I'm not sure that it's relevant to add information about how path are processed while exporting data there.


Considering this issue closed now, feel free to reopen if you consider some other places might be relevant :)