Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Save] index out of bounds when trying to save to a file from a gaml file outside of the workspace #318

Closed
chapuisk opened this issue Sep 9, 2024 · 3 comments · Fixed by #364
Assignees
Labels
😱 Bug The issue reveals a bug in GAMA 👍 Fix to be tested

Comments

@chapuisk
Copy link
Contributor

chapuisk commented Sep 9, 2024

Describe the bug
When calling the save statement in a model that is not in the workspace, Gama stoped with an index out of bounds exception

To Reproduce
Steps to reproduce the behavior:

  1. Create a txt file with extension .gaml anywhere in your computer
  2. copy/pass
global {
	init {
		save ["toto","tata"] to:"../res.csv" format:"csv";
	}	
}
experiment xp {}
  1. WARNING : don't forget to put model nameofyourfile as header of the file
  2. Import gaml file but do not copy it in workspace
  3. Launch the experiment
  4. See error

Expected behavior
Save statement works fine wherever the gaml file is

Desktop (please complete the following information):

  • OS: MacOS and Windows 10
  • PC Model: Laptops
  • GAMA version: git and 1.9.3

Context
During a training session, I share a gaml files with participants and many of them have the error

@chapuisk chapuisk added the 😱 Bug The issue reveals a bug in GAMA label Sep 9, 2024
@AlexisDrogoul
Copy link
Member

If the file is not copied, it is linked then, right ? Maybe there is a relation with #203 ?
In any case, can you copy and paste the stack in both macOS and Windows ?

@chapuisk
Copy link
Contributor Author

chapuisk commented Sep 9, 2024

  • To answer first question, yes ! I asked trainee to simply drag & drop file they downloaded into Gama.
  • Second question : yes it is related to the same issue, meaning that any I/O raises the same issues
  • Thrid:
    2 occurrences in 2 agents at cycle 0: Java error: index out of bounds
    in Simulation 0
    in init {
    save ['toto','tata'] format: 'csv' to: '../res.csv' ;
    }

ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
msi.gama.common.util.FileUtils.lambda$1(FileUtils.java:164)
java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
in agents Simulation 0, xp0

@AlexisDrogoul
Copy link
Member

@chapuisk can you test the code in the #364 PR ? This should close this issue.

@lesquoyb lesquoyb moved this from Todo to Done in GAMA 2024-11 Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
😱 Bug The issue reveals a bug in GAMA 👍 Fix to be tested
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants