Compare commits

...

39 Commits

Author SHA1 Message Date
KatKatKateryna fceeb6a9d7 remove unnecessary files 2023-02-13 21:40:35 +08:00
KatKatKateryna 8a27a3a8e2 Manual install instructions 2023-02-13 21:35:32 +08:00
KatKatKateryna 2540d05181 typo 2023-02-13 20:36:46 +08:00
KatKatKateryna 4cb57d9631 list directories 2023-02-13 20:33:32 +08:00
KatKatKateryna 007e6263a6 typo 2023-02-13 20:29:53 +08:00
KatKatKateryna 4a93b40e8e attach installer folder to workspace 2023-02-13 20:28:56 +08:00
KatKatKateryna 95c1495977 split tag version 2023-02-13 20:22:18 +08:00
KatKatKateryna fc07cbf60e add a context with github token 2023-02-13 20:15:09 +08:00
KatKatKateryna 07029675e4 remove token 2023-02-13 20:00:15 +08:00
KatKatKateryna f24ef49450 quote version 2023-02-13 19:52:44 +08:00
KatKatKateryna 52a531e040 debug 2023-02-13 19:46:40 +08:00
KatKatKateryna d3be4f0377 version syntax 2023-02-13 19:43:57 +08:00
KatKatKateryna 865964249c latest 2023-02-13 19:35:31 +08:00
KatKatKateryna 1d11e702dc go install 2023-02-13 19:33:47 +08:00
KatKatKateryna b454ac543c try another docker image 2023-02-13 19:31:47 +08:00
KatKatKateryna fcbdc9a200 remove whl step completely 2023-02-13 19:14:53 +08:00
KatKatKateryna 7cbdab0471 remove --64 2023-02-13 19:04:49 +08:00
KatKatKateryna 464bcf0f61 test another ghr installer 2023-02-13 19:03:11 +08:00
KatKatKateryna 97c8cebdb4 sudo 2023-02-13 18:58:37 +08:00
KatKatKateryna cd3a05103b add $ 2023-02-13 18:56:54 +08:00
KatKatKateryna cc11402470 remove powershell 2023-02-13 18:53:05 +08:00
KatKatKateryna ae0f15023c Update config.yml 2023-02-13 07:53:44 +08:00
KatKatKateryna 0eed167715 Merge pull request #52 from specklesystems/kate/2.12
tags fix, run on cmd
2023-02-13 07:48:44 +08:00
KatKatKateryna f60cd064f3 tags fix, run on cmd 2023-02-13 07:47:40 +08:00
KatKatKateryna b86799856e Merge pull request #51 from specklesystems/kate/2.12
Kate/2.12
2023-02-13 07:38:22 +08:00
KatKatKateryna 14e805cf99 typo 2023-02-13 07:37:19 +08:00
KatKatKateryna 6d35d13f99 ghr for adding files to release; separate job 2023-02-13 07:35:46 +08:00
KatKatKateryna 5e0ff316f0 add whl via powershell 2023-02-13 07:07:19 +08:00
KatKatKateryna b22ac2ef17 don't add whl to installer 2023-02-13 06:59:11 +08:00
KatKatKateryna da1ebb04e4 Merge branch 'main' into kate/2.12 2023-02-09 02:28:17 +08:00
KatKatKateryna 29c4fde0c5 handling access error to the account 2023-02-08 20:24:27 +08:00
KatKatKateryna e132b16878 refactoring unittests 2023-02-08 20:16:15 +08:00
KatKatKateryna 2e1dc329b3 add 2.11.3 whl 2023-02-02 16:52:02 +08:00
KatKatKateryna ee3cc81391 Merge branch 'main' into kate/2.12 2023-02-02 16:31:28 +08:00
KatKatKateryna 78063bc976 ci: add whl file to release 2023-02-02 16:24:38 +08:00
KatKatKateryna 8dcdfbbfc1 version name for metrics 2023-02-02 00:49:08 +08:00
KatKatKateryna 221a050df4 typings fix for python 3.7 2023-02-01 22:58:43 +08:00
KatKatKateryna 8721ae246a search limit for branches and commits increased from 10 to 100 2023-01-28 07:14:23 +08:00
KatKatKateryna 261d324ed4 folder naming (to save BIM mesh and raster bands) 2023-01-28 06:29:19 +08:00
19 changed files with 78 additions and 92 deletions
+24
View File
@@ -55,6 +55,21 @@ jobs:
root: ./
paths:
- speckle-sharp-ci-tools/Installers
- speckle_arcgis_installer
publish-github-release:
docker:
- image: cimg/go:1.20.0
steps:
- attach_workspace:
at: ./
- run:
name: "Publish Release on GitHub"
command: |
set -x
go install github.com/tcnksm/ghr@v0.16.0
VERSION="${CIRCLE_TAG:-0.0.0}"
VERSION_SHORT=$(echo "${VERSION}" | cut -d- -f1)
ghr -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete "${VERSION}" "./speckle_arcgis_installer/speckle_toolbox-${VERSION_SHORT}-py3-none-any.whl"
get-ci-tools: # Clones our ci tools and persists them to the workspace
docker:
@@ -142,6 +157,15 @@ workflows: #happens with every PR to main
branches:
ignore: /.*/
context: innosetup
- publish-github-release:
requires:
- build-deploy-connector-win
filters:
tags:
only: /([0-9]+)\.([0-9]+)\.([0-9]+)(?:-\w+)?$/
branches:
ignore: /.*/
context: arcgis-github-release
- deploy-manager2:
slug: arcgis
os: Win
+2 -2
View File
@@ -6,7 +6,7 @@ def patch_installer(tag):
iss_file = "speckle-sharp-ci-tools/arcgis.iss"
setup_whl_file = "setup.py"
conda_file = "speckle_arcgis_installer/conda_clone_activate.py"
toolbox_install_file = "speckle_arcgis_installer/toolbox_install.py"
#toolbox_install_file = "speckle_arcgis_installer/toolbox_install.py"
toolbox_manual_install_file = "speckle_arcgis_installer/toolbox_install_manual.py"
#py_tag = get_specklepy_version()
@@ -48,7 +48,7 @@ def patch_installer(tag):
file.close()
whlFileRename(conda_file)
whlFileRename(toolbox_install_file)
#whlFileRename(toolbox_install_file)
whlFileRename(toolbox_manual_install_file)
+3 -3
View File
@@ -1,10 +1,10 @@
### Manual installation
1. Download present "speckle_arcgis_installer" folder
2. Clone the default ArcGIS Pro conda environment and restart ArcGIS Pro
1. From the [latest release](https://github.com/specklesystems/speckle-arcgis/releases) download the whl file and the source code zip, unzip and locate the subfolder "speckle_arcgis_installer" on your machine and place whl file in it.
2. Clone the default ArcGIS Pro conda environment (or set the one you use, except the default one) and restart ArcGIS Pro
- for 2.9.0: Project-> Python-> Manage Environments-> Clone Default
- for 3.0.0: Project-> Package Manager-> Active Environment (Environment Manager)-> Clone arcgispro-py3
3. Change the path to your new environemnt Python.exe if necessary (variable "pythonPath" in "toolbox_install_manual.py")
3. Adjust the path to your new environment python executable (variable "pythonPath" in "speckle_arcgis_installer/toolbox_install_manual.py")
4. Enter the location of 'toolbox_install_manual.py' in the following command and run this command in ArcGIS Python console (View -> Python Window)
```python
@@ -1,3 +0,0 @@
@echo off
"%PROGRAMFILES%\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" "conda_clone_activate.py"
"%LOCALAPPDATA%\ESRI\conda\envs\arcgispro-py3-speckle\python.exe" "toolbox_install.py"
@@ -1,61 +0,0 @@
from subprocess_call import subprocess_call
import os
pythonPath = os.getenv('APPDATA').replace("\\Roaming","") + r"\Local\ESRI\conda\envs\arcgispro-py3-speckle\python.exe"
def installToolbox(newExec: str):
print("Installing Speckle Toolbox")
whl_file = os.path.join(os.path.dirname(__file__), "speckle_toolbox-2.9.4-py3-none-any.whl" )
print(whl_file)
subprocess_call([newExec, '-m','pip','install','--upgrade', '--force-reinstall', whl_file])
# to uninstall: cmd.exe "C:\\Users\\username\\AppData\\Local\\ESRI\\conda\\envs\\arcgispro-2.9.4-py3-none-any.whl
return
def installDependencies(pythonExec: str, pkgName: str, pkgVersion: str):
# install pip
print(pythonExec)
try:
import pip
except:
getPipFilePath = os.path.join(os.path.dirname(__file__), "get_pip.py") #TODO: give actual folder path
exec(open(getPipFilePath).read())
# just in case the included version is old
subprocess_call([pythonExec, "-m", "pip", "install", "--upgrade", "pip"])
# install package
try:
import importlib
importlib.import_module(pkgName)
except Exception as e:
print(f"{pkgName} not installed")
subprocess_call( [pythonExec, "-m", "pip", "install", f"{pkgName}=={pkgVersion}"])
# Check if package needs updating
try:
print(f"Attempting to update {pkgName} to {pkgVersion}")
result = subprocess_call(
[
pythonExec,
"-m",
"pip",
"install",
"--upgrade",
f"{pkgName}=={pkgVersion}",
]
)
if result == True:
print(f"{pkgName} upgraded")
return True
else:
return False
except Exception as e:
print(e)
print(e.with_traceback)
return True
installToolbox(pythonPath)
installDependencies(pythonPath, "specklepy", "2.9.0" )
installDependencies(pythonPath, "panda3d", "1.10.11" )
@@ -17,10 +17,10 @@ pythonPath = os.getenv('APPDATA').replace("\\Roaming","") + r"\Local\ESRI\conda\
def installToolbox(newExec: str):
print("Installing Speckle Toolbox")
mypath = os.path.dirname(__file__)
onlyfiles = [f for f in listdir(mypath) if (isfile(join(mypath, f)) and "-2.11.0-py3-none-any.whl" in str(f))]
onlyfiles = [f for f in listdir(mypath) if (isfile(join(mypath, f)) and "py3-none-any.whl" in str(f))]
onlyfiles.sort(key = lambda x: int(x.replace("speckle_toolbox-","").replace("-py3-none-any.whl","").split(".")[1]) )
whl_file = onlyfiles[len(onlyfiles)-1]
#whl_file = os.path.join(os.path.dirname(__file__), "speckle_toolbox-2.11.0-py3-none-any.whl" )
#whl_file = os.path.join(os.path.dirname(__file__), "speckle_toolbox-2.11.3-py3-none-any.whl" )
subprocess_call([newExec, '-m','pip','install','--upgrade', '--force-reinstall', whl_file])
return
@@ -213,7 +213,7 @@ def bimVectorLayerToNative(geomList, layerName: str, geomType: str, streamBranch
active_map = project.activeMap
path = project.filePath.replace("aprx","gdb") #
path_bim = "\\".join(project.filePath.split("\\")[:-1]) + "\\Layers_Speckle\\BIM_layers_speckle\\" + streamBranch+ "\\" + layerName + "\\" #arcpy.env.workspace + "\\" #
path_bim = "\\".join(project.filePath.split("\\")[:-1]) + "\\Layers_Speckle\\BIM_layers\\" + streamBranch+ "\\" + layerName + "\\" #arcpy.env.workspace + "\\" #
print(path_bim)
if not os.path.exists(path_bim): os.makedirs(path_bim)
@@ -680,7 +680,7 @@ def rasterLayerToNative(layer: RasterLayer, streamBranch: str, project: ArcGISPr
rasterHasSr = False
print(path)
path_bands = "\\".join(path.split("\\")[:-1]) + "\\Layers_Speckle\\rasters_Speckle\\" + streamBranch
path_bands = "\\".join(path.split("\\")[:-1]) + "\\Layers_Speckle\\raster_bands\\" + streamBranch
if not os.path.exists(path_bands): os.makedirs(path_bands)
try:
@@ -334,8 +334,8 @@ def rasterFeatureToSpeckle(selectedLayer: arcLayer, projectCRS: arcpy.SpatialRef
else:
#RGB colorizer
root_path = "\\".join(project.filePath.split("\\")[:-1])
if not os.path.exists(root_path + '\\Layers_Speckle\\rasters_Speckle'): os.makedirs(root_path + '\\Layers_Speckle\\rasters_Speckle')
path_style = root_path + '\\Layers_Speckle\\rasters_Speckle\\' + selectedLayer.name + '_temp.lyrx'
if not os.path.exists(root_path + '\\Layers_Speckle\\raster_bands'): os.makedirs(root_path + '\\Layers_Speckle\\raster_bands')
path_style = root_path + '\\Layers_Speckle\\raster_bands\\' + selectedLayer.name + '_temp.lyrx'
symJson = jsonFromLayerStyle(selectedLayer, path_style)
# read from Json
@@ -1,5 +1,5 @@
import json
from typing import Any, List, Union
from typing import Any, List, Tuple, Union
import copy
import os
@@ -163,7 +163,7 @@ def vectorRendererToNative(project: ArcGISProject, active_map, layerGroup, layer
else: return None
def get_rgb_from_speckle(rgb: int) -> tuple[int, int, int]:
def get_rgb_from_speckle(rgb: int) -> Tuple[int, int, int]:
r = g = b = 0
try:
r = (rgb & 0xFF0000) >> 16
@@ -174,7 +174,7 @@ def get_rgb_from_speckle(rgb: int) -> tuple[int, int, int]:
r,g,b = check_rgb(r,g,b)
return r,g,b
def check_rgb(r:int, g:int, b:int) -> tuple[int, int, int]:
def check_rgb(r:int, g:int, b:int) -> Tuple[int, int, int]:
if not isinstance(r, int) or r<0 or r>255: r=g=b=0
if not isinstance(g, int) or g<0 or g>255: r=g=b=0
@@ -208,9 +208,9 @@ def rasterRendererToNative(project: ArcGISProject, active_map, layerGroup, laye
# multiband raster, CIMRasterRGBColorizer
# arcpy doesnt support multiband raster symbology: https://community.esri.com/t5/arcgis-api-for-python-questions/why-does-arcpy-mp-arcgis-pro-2-6-mosaic-dataset/td-p/1016312
root_path = "\\".join(project.filePath.split("\\")[:-1])
if not os.path.exists(root_path + '\\Layers_Speckle\\rasters_Speckle'): os.makedirs(root_path + '\\Layers_Speckle\\rasters_Speckle')
path_style = root_path + '\\Layers_Speckle\\rasters_Speckle\\' + newName + '_old.lyrx'
path_style2 = root_path + '\\Layers_Speckle\\rasters_Speckle\\' + newName + '_new.lyrx'
if not os.path.exists(root_path + '\\Layers_Speckle\\raster_bands'): os.makedirs(root_path + '\\Layers_Speckle\\raster_bands')
path_style = root_path + '\\Layers_Speckle\\raster_bands\\' + newName + '_old.lyrx'
path_style2 = root_path + '\\Layers_Speckle\\raster_bands\\' + newName + '_new.lyrx'
symJson = jsonFromLayerStyle(arcLayer, path_style)
if renderer['type'] == 'singlebandgray':
@@ -308,8 +308,8 @@ def rendererToSpeckle(project: ArcGISProject, active_map, arcLayer, rasterFeat:
except:
rType = "multibandcolor"
root_path = "\\".join(project.filePath.split("\\")[:-1])
if not os.path.exists(root_path + '\\Layers_Speckle\\rasters_Speckle'): os.makedirs(root_path + '\\Layers_Speckle\\rasters_Speckle')
path_style = root_path + '\\Layers_Speckle\\rasters_Speckle\\' + arcLayer.name + '_temp.lyrx'
if not os.path.exists(root_path + '\\Layers_Speckle\\raster_bands'): os.makedirs(root_path + '\\Layers_Speckle\\raster_bands')
path_style = root_path + '\\Layers_Speckle\\raster_bands\\' + arcLayer.name + '_temp.lyrx'
#path_style2 = root_path + '\\' + newName + '_new.lyrx'
symJson = jsonFromLayerStyle(arcLayer, path_style)
@@ -89,7 +89,7 @@ class Toolbox:
try:
version = arcpy.GetInstallInfo()['Version']
python_version = f"python {'.'.join(map(str, sys.version_info[:2]))}"
metrics.set_host_app("ArcGIS", ', '.join([version, python_version]))
metrics.set_host_app("ArcGIS", ', '.join([f"ArcGIS {version}", python_version]))
except:
metrics.set_host_app("ArcGIS")
# https://pro.arcgis.com/en/pro-app/2.8/arcpy/mapping/alphabeticallistofclasses.htm#except: print("something happened")
@@ -127,6 +127,10 @@ class Speckle:
break
if self.toolboxInputs is None: self.toolboxInputs = toolboxInputsClass()
#print(self.speckleInputs.accounts)
if len(self.speckleInputs.accounts) == 0:
arcpy.AddError("Speckle accounts not found")
def getParameterInfo(self):
#data types: https://pro.arcgis.com/en/pro-app/2.8/arcpy/geoprocessing_and_python/defining-parameter-data-types-in-a-python-toolbox.htm
# parameter details: https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/customizing-tool-behavior-in-a-python-toolbox.htm
@@ -147,9 +151,12 @@ class Speckle:
if isinstance(self.speckleInputs.streams_default, SpeckleException):
arcpy.AddError("Speckle account not accessible")
streamsDefalut.filter.list = []
elif self.speckleInputs.streams_default is not None:
streamsDefalut.filter.list = [ (str(st.name) + " - " + str(st.id)) for st in self.speckleInputs.streams_default ]
else:
streamsDefalut.filter.list = [ (st.name + " - " + st.id) for st in self.speckleInputs.streams_default ]
streamsDefalut.filter.list = []
arcpy.AddError("Error connecting to default Speckle account")
addDefStreams = arcpy.Parameter(
displayName="Add",
name="addDefStreams",
@@ -341,7 +348,7 @@ class Speckle:
except: pass
# query stream, add to saved
stream = self.speckleInputs.speckle_client.stream.get(steamId)
stream = self.speckleInputs.speckle_client.stream.get(id = steamId, branch_limit = 100, commit_limit = 100)
if isinstance(stream, Stream):
print("_____Add by URL___")
wr = StreamWrapper(f"{self.speckleInputs.account.serverInfo.url}/streams/{stream.id}?u={self.speckleInputs.account.userInfo.id}")
@@ -5,7 +5,7 @@ from arcpy._mp import ArcGISProject, Map, Layer as arcLayer
from specklepy.api.models import Branch, Stream, Streams
import os.path
from specklepy.api.credentials import get_local_accounts
from specklepy.api.credentials import Account, get_local_accounts
from specklepy.api.client import SpeckleClient
from specklepy.logging.exceptions import (
GraphQLException,
@@ -18,9 +18,9 @@ class speckleInputsClass:
#def __init__(self):
print("CREATING speckle inputs first time________")
instances = []
accounts = get_local_accounts()
accounts: List[Account] = get_local_accounts()
account = None
streams_default: None or List[Stream] = None
streams_default: Optional[List[Stream]] = None
project = None
active_map = None
@@ -123,7 +123,7 @@ class speckleInputsClass:
except: pass
client = sw.get_client()
stream = client.stream.get(steamId)
stream = client.stream.get(id = steamId, branch_limit = 100, commit_limit = 100)
if isinstance(stream, GraphQLException):
raise SpeckleException(stream.errors[0]['message'])
return stream
+20 -1
View File
@@ -10,6 +10,13 @@ from specklepy.logging.exceptions import GraphQLException, SpeckleException
from specklepy.api.credentials import Account
import unittest # The test framework
# remove SetUp
# add different scenqrios for Streqm Wrapper including wrng ones
# tree of all options for input or class outcome
# use dict for types chech
# issue with untestable class init
# "mocking objects" for tests or "faking"
# get functions ut of INIT
class Test_InitializingClasses(unittest.TestCase):
def setUp(self) -> None:
@@ -17,7 +24,7 @@ class Test_InitializingClasses(unittest.TestCase):
self.speckle_input = speckleInputsClass()
self.toolbox = Toolbox()
self.speckleTool = Speckle()
self.test_stream = "https://speckle.xyz/streams/17b0b76d13"
self.test_stream = "https://speckle.xyz/streams////17b0b76d13"
def text_all_toolbox(self):
self.assertTrue(isinstance(self.toolbox.tools[0], Speckle))
@@ -34,6 +41,17 @@ class Test_InitializingClasses(unittest.TestCase):
self.assertIsNone(self.toolbox_input.project)
self.assertEqual(self.toolbox_input.stream_file_path, "")
def test_something(self):
# Arrange
toolbox_input: toolboxInputsClass = toolboxInputsClass()
# Act
toolbox_input.setProjectStreams(StreamWrapper(self.test_stream))
# Assert
os.path.exists(self.toolbox_input.stream_file_path)
def test_toolbox_inputs_functions(self):
self.toolbox_input.setProjectStreams(StreamWrapper(self.test_stream))
if os.path.exists(self.toolbox_input.stream_file_path):
@@ -48,6 +66,7 @@ class Test_InitializingClasses(unittest.TestCase):
existing_content = f.read()
f.close()
self.assertTrue(isinstance(existing_content, str))
self.assertIsInstance()
self.assertTrue( isinstance(self.toolbox_input.get_survey_point(), tuple))
self.assertTrue( isinstance(self.toolbox_input.get_survey_point()[0], float) or isinstance(self.toolbox_input.get_survey_point()[0], int))