yamcs / python-yamcs-client

Yamcs Client for Python
https://docs.yamcs.org/python-yamcs-client/
GNU Lesser General Public License v3.0
16 stars 11 forks source link

File Transfer Regression between v1.8.4 and v1.8.8 #24

Closed fgretief closed 1 year ago

fgretief commented 1 year ago

Some of our Python scripts stopped uploading files using CFDP class 2 after a yamcs-client upgrade from v1.8.4 to v1.8.8. The Python scripts now use CFDP class 1 only.

Our production server is Yamcs v5.7.9.2.

The Yamcs web interface still upload files CFDP class 2 when the "reliable" checkbox is selected. And I verified that the HTTP API is still working correctly. See code below.

The following Python snippet stopped working in v1.8.8:

                client = YamcsClient(args.yamcsServer)
                cfdp = client.get_file_transfer_client(instance=args.yamcsInstance).get_service("cfdp0")

                upload = cfdp.upload(uplink_bucket_name, fileName, dst_filename,
                                     destination_entity=args.yamcsDestinationEntityId,
                                     reliable=True)

                if not upload.reliable:
                    print("BUG: expected a reliable upload from Yamcs server")
                #print(upload)

The following code still works on v1.8.8:

                api_url = f"http://{args.yamcsServer}/api/filetransfer/{args.yamcsInstance}/cfdp0/transfers"
                import requests
                resp = requests.post(api_url, json={
                    "direction": "UPLOAD",
                    "bucket": f"{uplink_bucket.name}",
                    "objectName":f"{fileName}",
                    "remotePath":f"{dst_filename}",
                    "destination":args.yamcsDestinationEntityId,
                    "uploadOptions":{
                        "reliable":True
                    }
                })
                upload = resp.json()
                if not upload["reliable"]:
                    print("BUG: expected a reliable upload from Yamcs server")
                #print(upload)
loricvdt commented 1 year ago

Hi, The way file transfer options (such as reliable) get sent has changed. Although the REST API still supports (for now) the old method for backwards compatibility, the new versions of the Python client only sends them the new way: via the options parameter (described here). You could either upgrade the server to Yamcs 5.7.13, or use an older version of the Python client. (uploadOptions and downloadOptions in the API are deprecated since 5.7.10, and overwrite, parents and reliable are deprecated in the Python client since 1.8.7)