Forum

Author Topic: RunScript() dont run over network  (Read 19617 times)

3dlancer

  • Newbie
  • *
  • Posts: 2
    • View Profile
RunScript() dont run over network
« on: March 05, 2024, 12:50:02 PM »
I am encountering an issue where tasks submitted for batch processing through both the Metashape GUI and Python scripts do not initiate. The core of the problem seems to be that no workers are assigned to the tasks, showing a status of 0/0 workers, regardless of the submission method. This occurs during the following process:

1. In the Metashape GUI, I navigate to Workflow -> Batch Process -> Add -> Run Script, then select any file and submit it to the network. However, the task does not start due to 0/0 workers being assigned.
2. Similarly, when submitting a Run Script task via Python, the same issue of 0/0 workers being assigned is observed.

I found a temporary workaround by exporting the batch tasks from the monitor, manually editing the XML to set the worker count to 1, and then reimporting it. After this manual adjustment, the script processes as expected.

I am inquiring if there exists a more streamlined workaround or a feature that allows for the direct submission of tasks with scripts over the network. Specifically, is it possible to submit custom JSON or XML directly to the Metashape server, bypassing the need to use the RunScript() function?

Additionally, it would be immensely beneficial if there was a way to specify the number of workers when submitting a script for batch processing. Ideally, setting this number to, for example, 3, would enable the script to run in parallel across three machines. This would not only bypass the limitation of restricting a batch script to a single machine but also enhance efficiency by leveraging parallel processing capabilities. The logic for parallel processes could be embedded within the Python script itself, necessitating only the addition of a parameter to dictate the desired number of executions.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15471
    • View Profile
Re: RunScript() dont run over network
« Reply #1 on: March 05, 2024, 01:07:45 PM »
Hello 3dlancer,

This bug has been reported recently and will be fixed in the next version update.

You can use 2.1.1 pre-release (should be updated both on nodes and server):
https://s3-eu-west-1.amazonaws.com/download.agisoft.com/metashape-pro_2_1_1_x64.msi
https://s3-eu-west-1.amazonaws.com/download.agisoft.com/metashape-pro_2_1_1.dmg
https://s3-eu-west-1.amazonaws.com/download.agisoft.com/metashape-pro_2_1_1_amd64.tar.gz
Best regards,
Alexey Pasumansky,
Agisoft LLC

3dlancer

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: RunScript() dont run over network
« Reply #2 on: March 06, 2024, 11:52:39 AM »
Thanks for helping, submitting now seems to start the script but I encountered a new challenge

Issue: Import operations in test.py hang when executed via Runscript over a network, notably the import cv2, pymeshlab command, while the same import works in main.py.
Environment: Server and client operations occur on the same machine, with an identical environment setup for both main.py and test.py. The issue is confirmed under these conditions, with no other machine involved.

Observation: Some imports like tqdm function correctly, yet most others do not and result in a hang without any error output.

Testing Conditions: The problem is specific to networked script execution through Runscript. Direct imports in main.py or from the script initiating the Runscript task work as expected.

Actions Taken:
Confirmed both main.py and test.py run under the same Python environment, versions, and paths. This was verified by a utility function (show_python_info) that outputs the Python version, installation directory, site-packages directory, Python search paths (sys.path), system platform, and Python executable. Results were consistent across both scripts.

For Replication:
Test by executing a script containing import cv2 via Runscript over a network. Observe the hanging issue during the import process.

benj_G

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: RunScript() dont run over network
« Reply #3 on: August 23, 2024, 05:52:12 PM »
Hi I have exactly the same problem with 2.1.2 b18548.

I can add that if I cancel the job in Agisoft Monitor, the script executes correctly after the "#abord" but of course the rest of the jobs do not.

I support 3dlancer. Because as you can see in the screenshot the previous "Runscript" as a import only of 'Metashape and sys' and works correctly.
for me too the script run good on local machine

and just to know :
- align cameras
- filter tie_cloud
- optimizeCam
- footprints_to_shapes.py from github


can you please make it work again.
« Last Edit: August 23, 2024, 05:56:48 PM by benj_G »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15471
    • View Profile
Re: RunScript() dont run over network
« Reply #4 on: August 23, 2024, 06:14:43 PM »
Hello benj_G,

GitHub script  footprints_to_shapes.py adds Custom Menu item to the main menu when executed via Run Script command. If you would like to have it running via Batch Process, you should modify it so that only processing function is called instead of menu item creation.
Best regards,
Alexey Pasumansky,
Agisoft LLC

benj_G

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: RunScript() dont run over network
« Reply #5 on: August 26, 2024, 09:37:53 AM »
Yes I know ! I have modify it to be processed in network mode.
see attached the footprint_to_shape.py (modified) that not working
and filter_tie_point.py that work.

don't take care of JsonFile class / jsonInfo object is just a json with info for us. and it's commented for debugging.
« Last Edit: August 26, 2024, 09:56:50 AM by benj_G »

benj_G

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: RunScript() dont run over network
« Reply #6 on: March 31, 2025, 10:02:07 AM »
Hi everybody,
Any news on this ?

I'm still stuck on this in the latest version...

I make :

Code: [Select]
& 'C:\Program Files\Agisoft\Metashape Pro\python\python.exe' -m pip install geopandas pyproj shapely pandas numpy fiona
everything is installed. (In GUI import geopandas is ok)

but went I run the script attached by:

Code: [Select]
task = Metashape.Tasks.RunScript()
in network processing it's still blocked...

in GUI not.

I have activated --verbose options in server and worker and I don't have message


Any one have the same problems ?



EDIT:
on example_stuck.py if I uncomment "geopandas" and "Shapely" it's run ok.
« Last Edit: March 31, 2025, 11:02:58 AM by benj_G »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15471
    • View Profile
Re: RunScript() dont run over network
« Reply #7 on: April 01, 2025, 08:30:07 PM »
Hello benj_G,

Thanks, we will try to analyze and fix this problem before 2.2.1 release.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15471
    • View Profile
Re: RunScript() dont run over network
« Reply #8 on: April 09, 2025, 03:29:06 PM »
Hello benj_G,

It appears that you should be able to resolve the observed issue in 2.x version by adding --inprocess command-line argument when starting the worker nodes. Let me know, if it workaronds the problem for you.
Best regards,
Alexey Pasumansky,
Agisoft LLC

benj_G

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: RunScript() dont run over network
« Reply #9 on: April 10, 2025, 09:23:50 AM »
Hi ! seems to do the tricks ! thanks a lot !
 ;D

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15471
    • View Profile
Re: RunScript() dont run over network
« Reply #10 on: April 11, 2025, 11:40:07 AM »
Good to hear that!

We'll try, however, to analyze it further. Probably it is the version of numpy that is causing the problem in such case.
Best regards,
Alexey Pasumansky,
Agisoft LLC