Skip to content

Commit

Permalink
fixed escaping, updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jessjaco committed Jan 25, 2024
1 parent 5fb7e58 commit 9ed9ac7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 42 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Circuitscape Python Script Tool for ESRI Arc Pro
# Circuitscape Python Script Tool for ArcGIS Pro

## Installation and Usage

Expand Down Expand Up @@ -28,18 +28,12 @@ and run via python using `subprocess.Popen`.
## Bugs and Caveats

The limitations of Arc Pro Python script tools as well as Python <-> Julia interprocess communications necessitate
certain limitations. Among these

1. There is no way to cancel running jobs.
Using the 'cancel' option in a running tool is typically ineffective (Arc Pro only cancels a python script between
lines). To cancel a running process, you will need to exit Arc Pro completely (or kill it in task manager).
1. Errors do not always show as failed runs in Arc Pro. To be sure, click "View Details".
1. The tool does not respect any environment settings in Arc Pro.
certain limitations. See [src/INSTALL.md](src/INSTALL.md) for more information.

Please report other issues at
https://github.com/jessjaco/circuitscape-arc-pro/issues.

## Acknowledgements

The tool was authored by Jesse Anderson and guided by Kimberly Hall with The Nature Conservancy. Funding for this
The tool was authored by Jesse Anderson as guided by Kimberly Hall with The Nature Conservancy. Funding for this
project was provided by The Wilburforce Foundation.
2 changes: 2 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
julia*
config.ini
last_config.ini
2 changes: 1 addition & 1 deletion src/Circuitscape.pyt.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata xml:lang="en"><Esri><CreaDate>20231024</CreaDate><CreaTime>13520600</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><ModDate>20231024</ModDate><ModTime>135206</ModTime></Esri><toolbox name="Circuitscape" alias="Circuitscape"><arcToolboxHelpPath>c:\program files\arcgis\pro\Resources\Help\gp</arcToolboxHelpPath><toolsets/></toolbox><dataIdInfo><idCitation><resTitle>Circuitscape</resTitle></idCitation></dataIdInfo><distInfo><distributor><distorFormat><formatName>ArcToolbox Toolbox</formatName></distorFormat></distributor></distInfo></metadata>
<metadata xml:lang="en"><Esri><CreaDate>20231024</CreaDate><CreaTime>13520600</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><ModDate>20240124</ModDate><ModTime>133140</ModTime></Esri><toolbox name="Circuitscape" alias="Circuitscape"><arcToolboxHelpPath>c:\program files\arcgis\pro\Resources\Help\gp</arcToolboxHelpPath><toolsets/></toolbox><dataIdInfo><idCitation><resTitle>Circuitscape</resTitle></idCitation></dataIdInfo><distInfo><distributor><distorFormat><formatName>ArcToolbox Toolbox</formatName></distorFormat></distributor></distInfo></metadata>
31 changes: 27 additions & 4 deletions src/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,38 @@ Navigate to the unzipped location and select "Circuitscape.pyt".

## Usage

The Circuitscape Toolbox shadows the full functionality of Circuitscape in Julia.
Simply parameterize and hit run. A blank black shell window will pop up, which
you can ignore. To monitor while running , select "View Details" at the bottom
The toolbox shadows the full functionality of Circuitscape and Omniscape in Julia.
Simply parameterize and hit run. To monitor while running , select "View Details" at the bottom
of the Arc Pro Toolbox window.

Please note the first model run will take longer than usual, as the tool is
downloading, installing and testing Circuitscape.
downloading, installing and testing Circuitscape and Omniscape.

## Circuitscape tips
The parameterization of the output file is a bit clunky. If it's not clear by the help bubble,
you need to specify a new file with an ".out" extension. If using the file browser, navigate
to the folder you wish the place the output, and type a name ending in .out (e.g. "model.out")
and the bottom, then hit OK.

## Omniscape tips
The output location for Omniscape (the "Project Name" dialog) is a folder. Otherwise it is best
to define it similarly to the Circuitscape instructions above. That is, navigate to a location
and type the name of the (new) folder at the bottom. If you use an existing folder, an
exclamation point will appear in the tool window, but it will still run.

The JULIA_NUM_THREADS environment variable, which defines the number of parallel threads to use
is represented by the "Number of Threads" parameter under "Calculation Options". Just noting
as this (along with making sure "Parallelize" is checked) can speed up calculations immensely.
(See Omniscape documentation for more info).


## Known Issues

- Sometimes when you add the toolbox in Arc Pro, it doesn't appear. For now the best
solution is to exit Arc Pro and try again.

- There is no way to cancel running jobs. Using the 'cancel' option in a running tool is typically
ineffective (Arc Pro only cancels a python script between lines). To cancel a running process,
you will need to exit Arc Pro completely (or kill it in task manager).
- Errors do not always show as failed runs in Arc Pro. To be sure, click "View Details".
- The tool does not respect any environment settings in Arc Pro.
26 changes: 0 additions & 26 deletions src/last_config.ini

This file was deleted.

4 changes: 2 additions & 2 deletions src/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@


def run_circuitscape(config_file: Path, command_args: dict, messages) -> None:
working_dir = Path(__file__).resolve().parent
working_dir = str(Path(__file__).resolve().parent).replace("\\", "/")
config_file_fixed = str(config_file).replace("\\", "/")
command = f'"using Pkg; Pkg.activate(realpath(\\"{working_dir}\\")); Pkg.instantiate(); using Circuitscape; compute(realpath(\\"{config_file_fixed}\\"))"'
return run_julia_command(command, command_args, messages)


def run_omniscape(config_file: Path, command_args: dict, messages) -> None:
working_dir = Path(__file__).resolve().parent
working_dir = str(Path(__file__).resolve().parent).replace("\\", "/")
config_file_fixed = str(config_file).replace("\\", "/")
command = f'"using Pkg; Pkg.activate(realpath(\\"{working_dir}\\")); Pkg.instantiate(); using Omniscape; run_omniscape(realpath(\\"{config_file_fixed}\\"))"'

Expand Down

0 comments on commit 9ed9ac7

Please sign in to comment.