Forum

Author Topic: How to process relative network paths (diff drive) in python same as in batch?  (Read 2150 times)

andyroo

  • Sr. Member
  • ****
  • Posts: 463
    • View Profile
Help this has been driving me nuts for MONTHS!!!
TLDR; I can't figure out how to run scripts that work on different shared drives from the same network host, even though it works fine in batch:

I have a network set up with a host and a handful of worker nodes (windoze).First I set up a single shared drive on the host and used that as the network location (Root) in the client/gui:

\\SFM-HOST\Network_SfM

I launch the server and workers with this:
"C:\Program Files\Agisoft\Metashape Pro\metashape.exe" --server --dispatch 192.168.88.205 --root //SFM-HOST/Network_SfM

and this
"c:\Program Files\Agisoft\Metashape Pro\metashape.exe" --node --dispatch 192.168.88.205 --root //SFM-HOST/Network_SfM

That worked fine. Then I added more mapped drives and used them for network processing:

\\sfm-host\Network_RAID5_HDD
\\sfm-host\4x4TB_striped

When network processing on Metashape (2.x) I can make a project and do network processing in batch mode on any of these mapped shares. From the Monitor I can look at project details (right-click context) and it shows the path as a relative path, for example:

..\4x4TB_striped\SantaBarbara\psx\multiband_propagate_masks_test.psx

the workers also handle the different path just fine but report the whole path, e.g.:

2024-11-13 17:13:34 AlignCameras.initialize (1/1): subtask = initialize, adaptive_fitting = off, reset_alignment = on, cache_path = //SFM-HOST/4x4TB_striped/SantaBarbara/psx/multiband_propagate_masks_test.files/13/align
2024-11-13 17:13:34 processing matches... done in 0.008 sec


BUT, if I try to run a simple network processing script from anywhere but the mounted path, I get a path error no matter what I try, either:

Error: path is on mount '\\\\SFM-HOST\\4x4TB_striped', start on mount '\\\\SFM-HOST\\Network_SfM' (from ntpath.py)
or
Error: Request failed with error: Duplicate batch: ../4x4TB_striped/SantaBarbara/psx/multiband_propagate_masks_test.psx (metashape)

simple script code:
Code: [Select]
import Metashape, os
#reference document the script was run from
doc = Metashape.app.document
chunk = doc.chunk
task = Metashape.NetworkTask()
task.name = 'MatchPhotos'
task.params['keypoint_limit'] = 60000
client = Metashape.NetworkClient()
#use host address specified in the app/node
client.connect(Metashape.app.settings.network_host)
print('connected to', Metashape.app.settings.network_host)

#use path of existing doc - note that this has to be relative to the network root in network settings

#this ONLY works with network projects on the same drive as mapped host drive
#batch_path = os.path.relpath(doc.path,Metashape.app.settings.network_path)
#this doesn't work - gives "duplicate batch error"
batch_path = os.path.normpath(doc.path)

print('batch_path = ', batch_path)
print('chunk = ', doc.chunk)
#try this
batch_id = client.createBatch(batch_path, [task])
client.setBatchPaused(batch_id, False)

and the worker shows this error if the first batch_path variable is assigned:
2024-11-13 17:24:14 RunScript: path = //SFM-HOST/Network_SfM/python_scripts/network_match_test.py
2024-11-13 17:24:14 connected to 192.168.88.205:5840
2024-11-13 17:24:14 connected to 192.168.88.205
2024-11-13 17:24:14 Traceback (most recent call last):
2024-11-13 17:24:14   File "//SFM-HOST/Network_SfM/python_scripts/network_match_test.py", line 15, in <module>
2024-11-13 17:24:14     batch_path = os.path.relpath(doc.path,Metashape.app.settings.network_path)
2024-11-13 17:24:14   File "c:\Program Files/Agisoft/Metashape Pro/python\lib\ntpath.py", line 703, in relpath
2024-11-13 17:24:14     raise ValueError("path is on mount %r, start on mount %r" % (
2024-11-13 17:24:14 ValueError: path is on mount '\\\\SFM-HOST\\4x4TB_striped', start on mount '\\\\SFM-HOST\\Network_SfM'
2024-11-13 17:24:14 Error: path is on mount '\\\\SFM-HOST\\4x4TB_striped', start on mount '\\\\SFM-HOST\\Network_SfM'
2024-11-13 17:24:14 processing failed in 0.218 sec

or this error if the second batch_path variable is assigned:
2024-11-13 17:42:39 RunScript: path = //SFM-HOST/Network_SfM/python_scripts/network_match_test.py
2024-11-13 17:42:39 connected to 192.168.88.205:5840
2024-11-13 17:42:39 connected to 192.168.88.205
2024-11-13 17:42:39 batch_path =  \\SFM-HOST\4x4TB_striped\SantaBarbara\psx\multiband_propagate_masks_test.psx
2024-11-13 17:42:39 chunk =  <Chunk 'Chunk 1'>
2024-11-13 17:42:39 Traceback (most recent call last):
2024-11-13 17:42:39   File "//SFM-HOST/Network_SfM/python_scripts/network_match_test.py", line 22, in <module>
2024-11-13 17:42:39     batch_id = client.createBatch(batch_path, [task])
2024-11-13 17:42:39 RuntimeError: Request failed with error: Duplicate batch: ../4x4TB_striped/SantaBarbara/psx/multiband_propagate_masks_test.psx
2024-11-13 17:42:39 Error: Request failed with error: Duplicate batch: ../4x4TB_striped/SantaBarbara/psx/multiband_propagate_masks_test.psx
2024-11-13 17:42:39 processing failed in 0.216 sec