-
Notifications
You must be signed in to change notification settings - Fork 355
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
Remove scripts created by batch #5216
Conversation
Without -W the content of the prefix script would leave behind script files produced by batch. These are now removed via this PR. Also changed the -Zs to -Z in the documentation example since there is no s directive.
It partially worked. All the files were removed but I still have the folder. |
Yes, but it is possible the scripts will produce things in there. I need to look at the logic a bit more to see if it is always "safe" to remove the prefix directory or not. |
I am concerned by these lines in the docs under -W:
I am not sure if that is actually true (for starters) or desired. |
We also say (under Parameters): So there are many mixed messages here which I think gives us some flexibility in deciding how to solve it. Much of the machinery of batch was inherited from movie, but there are some big differences between movie and batch (and some similarities):
I think we should declare that we have a bug here and that all products named via BATCH_NAME shall be present in the prefix directory when the command finishes. There is no way of knowing if there is a single final master product (such as the countries.pdf book based on all the individual files in the man page example) or a bunch (such as all the grids produced in the other example). Furthermore, the user could always place a mv command in the post-script to place result(s) elsewhere. Finally, since the pre.sh script may create some temporary files in the prefix folder it is not possible to know in general what that is (and delete them specifically), but one solution is to get the list of all the files present in prefix after the run is completed and then delete all those does not match the BATCH_NAME prefix. So in summary, I propose this (modified) behavior and corresponding documentation improvements:
Comments on these, @GenericMappingTools/core ? |
I am making one change to the above suggestions: While products called BATCH_TAG.* will be left in the prefix directory (the equivalent of the PNG files like prefix_0001., prefix_0002.), anything called BATCH_NAME.* will be moved up to the top directory. This gives nice flexibility of leaving lots of numbered files in the prefix directory while letting final summaries (such as countries.pdf) be placed outside (and thus removing the empty prefix directory). |
I have now implemented the items discussed above. Perhaps @Esteban82 would like to test? The key changes are
The two batch examples have been modified slightly. Because some things might be OS-dependent it would be good to test this on Windows and Linux as well as macOS. |
It worked fine with the example 2 of batch. Then I try it in another script where I use this command in the post script:
The files are rename but I all the scripts are not deleted (main.sh, include.sh, post.sh in the main directory and batch_init.sh, batch_job.sh and batch_postfligth.sh in the workdir). Not sure if there is an issue with the previous command or with batch module. In the terminal I got this error:
|
Hard to tell what is happening but if the postflight script fails then we exit before we examine the files and delete the ones you found are there. Could you place your full post script here please? You could also run with -Qs with just a few jobs so you can run that script manually and see if there is something odd with it. |
I am not sure if the postflight fails because all the files were renamed fine. The full script is
Data for the script: Datos.zip |
It ran for me after I removed the ../ in fromt of Estaciones.txt. Probably related to the updated batch.c where post now runs inside the working directory. |
Sorry. I don't understand if you have any problem or not (besides the ../). |
Once I removed the ../ I had no problems - it ran fine. WIth the ../ it failed. |
Mmm. I am getting an error in both cases. |
Are you using the batch.c version from this PR? One thing that this update does is to change the current directory when the post script is run. It used to run from outside the -N work directory but now, like in movie, it is inside so that it can benefit from knowing where all the data files are. While gmt modules can find data files both in the top directory and in the work directory (since we set GMT_DATA path in the scripts that are created, there is no such mechanism for arbitrary unix commands of course (e.g., gawk) so here you need to be exact. I suspect you are running the above script with master or 6.1.1? |
I am using Version 6.2.0_5e69197-dirty_2021.05.14 and the batch-delete branch. |
Current version seems to work great for me, with moving products up to top and leaving any name_##### files in the workdir which is then not removed. However, it causes a problem with the 2nd example on the man page in that the gmt end show command in the post script cannot find the plot since it has been moved up to the top. If the rule is that products shall move up then we cannot name this plot filter.pdf |
For me works fine too if I removed the postflight script with the gawk command. With it, I still can't managed to renamed the files but most likely it is because I am using gawk wrong. |
Hi @Esteban82, I just updated this branch with master and fixed the conflicts (it has been sitting here sin 2021). Could you run your case again and see how it goes? |
@PaulWessel I think that there is an error in the code. I got this error while trying to build this branch:
|
Sorry, what happens when merging Nov 2023 master into 2001 branch (> 1000 commits and conflicts). I just did not notice that the build failed before I added it. Now fixed I hope. |
It is working fine. |
I think we can merge it. |
See the forum for context. Without -W the content of the prefix script would leave behind script files produced by batch. These are now removed via this PR. Also changed the -Zs to just -Z in the documentation example since there is no s directive.