Publishing an SD file containing a geoprocessing service fails in a disconnected environment
- Ngôn ngữ chính
- Python
- Star
- 2.2k
- Fork
- 1.2k
- Merge trung bình
- 2 giờ 40 phút
- Pull request đã merge (30 ngày)
- 2
Mô tả
**Describe the bug**
We have created a custom print service. When using the ArcGIS Python API 2.1 to publish this to an ArcGIS Server **in a disconnect / offline environment**, we first get a warning:
_Using Connection object over GIS object_
then directly the error:
_A connection error has occured: HTTPSConnectionPool(host='www.arcgis.com', port=443): Max retries exceeded with url: /sharing/rest/portals/self (Caused by NewConnectionError)_
**The problem is the new GIS-object being created in arcgis/geoprocessing/_support.py on line 378 to 384, where the Python API creates a new GIS object with no URL specified, which means it will try to reach out to www.arcgis.com per default.**
**To Reproduce**
Steps to reproduce the behavior:
Create an SD-file for a print service (probably other GP Services will fail as well)
```python
from arcgis.gis import GIS
gis = GIS("https://myportal.com/portal", "user", "pass")
sd_file = r"C:\temp\prinservice.sd"
# Get the first federated server
target_server = gis.admin.servers.list()[0]
target_server.publish_sd(sd_file)
```
error:
```python
A connection error has occured: HTTPSConnectionPool(host='www.arcgis.com', port=443): Max retries exceeded with url: /sharing/rest/portals/self (Caused by NewConnectionError)
```
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Platform (please complete the following information):**
- OS: Windows Server 2022
- Python API Version 2.1
**Additional context**
The problem is the new GIS-object being created in arcgis/geoprocessing/_support.py on line 378 to 384, where the Python API creates a new GIS object with no URL specified, which means it will try to reach out to www.arcgis.com per default.
Problematic code, which can be worked around by commenting out the following (might cause other stuff to break?):
```python
if isinstance(gis, Connection):
log = logging.getLogger()
log.warning("Using Connection object over GIS object")
ngis = GIS(set_active=False)
ngis._con = gis
gis = ngis
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với các dòng 378-384 trong arcgis/geoprocessing/_support.py và tái hiện lỗi được nêu trong issue bằng GIS, máy chủ liên kết đầu tiên và publish_sd(). Theo dõi cách đối tượng GIS được tạo khi cung cấp một Connection, sau đó xác minh rằng việc xuất bản tệp SD lên portal bị ngắt kết nối không còn cố gắng truy cập www.arcgis.com.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- api, backend-api-design
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 48/100