POST
|
As the guys over on the Workforce Scripts GitHub tell me they are deprecating the Python Standalone scripts, I'm trying hard to get the ArcGIS API Jupyter Notebook up and running under Docker, and migrating my tweaked scripts into the Notebook. None of the old example scripts for Workforce are included - and I wondered if there's any appetite for adding them to the official Jupyter Notebook to encourage adoption and use among the growing Esri target audience? Thanks.
... View more
02-26-2018
03:47 AM
|
0
|
0
|
356
|
POST
|
Hi Craig. Here's the bash script (create_assignments_onprem.sh) I use to run the Enterprise assignments upload from csv: #!/bin/bash # Onwave 2017 # Runs Python script: create_assignments_from_csv.py # which imports WorkForce assignments from a csv file named inputfile.csv # csv format thus: # Header row: xField,yField,Type,Location,Dispatcher,Description,Priority,Work Order Id,Due date,attachment # Body rows follow this layout, comma separated, no trailing spaces. # Field descriptions: # xField = x coord (longitude) as decimal value # yField = y coord (latitude) as decimal value # Type = type of assignment (must be an integer) # Location = Description of location, i.e. address # Dispatcher = Name of Dispatcher adding data (perhaps use version of schedule file?) # Priority = Priority rating # Work Order Id = Job identity # Due Date = Date job must be completed by # attachment = Filename of file to attach # worker = name of worker # # This version updated to allow for On-Prem WorkForce - Oct 2017 - Jonathan Groves # Build parameter string (q): q="sudo python create_assignments_from_csv.py " # csv filename: q+="-csvFile \"./inputfile.csv\" " # Username: q+="-u \"Jonathan.Groves\" " # Password: q+="-p \"xxxx\" " # url: q+="-url \"https://xxxx\" " # Project ID: q+="-pid \"xxxx\" " # xField - name of xField column: q+="-xField \"xField\" " # yField: q+="-yField \"yField\" " # Type: q+="-assignmentTypeField \"Type\" " # Location: q+="-locationField \"Location\" " # Description: q+="-descriptionField \"Description\" " # Priority: q+="-priorityField \"Priority\" " # Work order Id: q+="-workOrderIdField \"Work Order Id\" " # Dispatchers: q+="-dispatcherIdField \"Dispatcher\" " # due date: q+="-dueDateField \"Due Date\" " # attachment: q+="-attachmentFileField \"attachment\" " # wkid - spatial reference used by xField and yField # NB defaults to 4236 (GCS_WGS_1984) #q+="-wkid 102100 " # Logfile: q+="-logFile \"./log.txt\" " # Worker: q+="-workerField \"Worker\" " # Timezone: q+="-timezone \"US/Eastern\" " # Debug: #echo ">"$q"<" eval $q Here is the output when I run it: ./create_assignments_onprem.sh [2017-11-02 10:05:36,356] [create_assignments_from_csv.py: 261 - main()] [MainThread] [ root] [ INFO] Authenticating... [2017-11-02 10:05:36,608] [create_assignments_from_csv.py: 345 - <module>()] [MainThread] [ root] [CRITICAL] Exception detected , script exiting [2017-11-02 10:05:36,609] [create_assignments_from_csv.py: 346 - <module>()] [MainThread] [ root] [CRITICAL] No JSON object cou ld be decoded [2017-11-02 10:05:36,612] [create_assignments_from_csv.py: 347 - <module>()] [MainThread] [ root] [CRITICAL] Traceback (most re cent call last): | File "create_assignments_from_csv.py", line 343, in <module> | main(args) | File "create_assignments_from_csv.py", line 263, in main | token = workforcehelpers.get_token(args.org_url, args.username, args.password) | File "/home/pi/arcgis/workforcehelpers.py", line 78, in get_token | res ponse = post(url, data) | File "/home/pi/arcgis/workforcehelpers.py", line 40, in post | response = requests.post(url, data, files=files).json() | File "/ usr/local/lib/python2.7/dist-packages/requests/models.py", line 885, in json | return complexjson.loads(self.text, **kwargs) | File "/usr/lib/python2.7/json /__init__.py", line 338, in loads | return _default_decoder.decode(s) | File "/usr/lib/python2.7/json/decoder.py", line 366, in decode | obj, end = self .raw_decode(s, idx=_w(s, 0).end()) | File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode | raise ValueError("No JSON object could be decoded" ) | ValueError: No JSON object could be decoded | I successfully ran my original script on the Client's AGOL-based Workforce yesterday using exactly the same input file - here's that script (create_assignments_production.sh): #!/bin/bash # go.sh - Onwave 2017 # Runs Python script: create_assignments_from_csv.py # which imports WorkForce assignments from a csv file named inputfile.csv # csv format thus: # Header row: xField,yField,Type,Location,Dispatcher,Description,Priority,Work Order Id,Due date,attachment # Body rows follow this layout, comma separated, no trailing spaces. # Field descriptions: # xField = x coord (longitude) as decimal value # yField = y coord (latitude) as decimal value # Type = type of assignment (must be an integer) # Location = Description of location, i.e. address # Dispatcher = Name of Dispatcher adding data (perhaps use version of schedule file?) # Priority = Priority rating # Work Order Id = Job identity # Due Date = Date job must be completed by # attachment = Filename of file to attach # worker = name of worker # Build parameter string (q): q="sudo python create_assignments_from_csv.py " # csv filename: q+="-csvFile \"./inputfile.csv\" " # Username: q+="-u \"Jonathan.Groves\" " # Password: q+="-p \"xxxx\" " # url: q+="-url \"https://xxxx.maps.arcgis.com\" " # Project ID: q+="-pid \"xxxx\" " # xField - name of xField column: q+="-xField \"xField\" " # yField: q+="-yField \"yField\" " # Type: q+="-assignmentTypeField \"Type\" " # Location: q+="-locationField \"Location\" " # Description: q+="-descriptionField \"Description\" " # Priority: q+="-priorityField \"Priority\" " # Work order Id: q+="-workOrderIdField \"Work Order Id\" " # Dispatchers: q+="-dispatcherIdField \"Dispatcher\" " # due date: q+="-dueDateField \"Due Date\" " # attachment: q+="-attachmentFileField \"attachment\" " # wkid - spatial reference used by xField and yField # NB defaults to 4236 (GCS_WGS_1984) #q+="-wkid 102100 " # Logfile: q+="-logFile \"./log.txt\" " # Worker: q+="-workerField \"Worker\" " # Timezone: q+="-timezone \"US/Eastern\" " # Debug: #echo ">"$q"<" eval $q As you can see, the only differences between the two is the url and the PID. Oh - here's a snippet of the csv file: xField,yField,Type,Location,Dispatcher,Description,Priority,Work Order Id,Due Date,attachment,Worker 0.101466667,50.77328333,1,Seaford,1,Cut 6,3,USFD,10/23/2017 23:59:59,,eshgrass1 0.195244444,50.85660278,1,Upper Dicker,1,Cut 6,3,UUDK,10/30/2017 23:59:59,,eshgrass1 0.166230556,50.83036389,1,Berwick,1,Cut 6,3,UBRK,10/30/2017 23:59:59,,eshgrass1 0.156430556,50.80839167,1,Alfriston,1,Cut 6,3,UALF,10/30/2017 23:59:59,,eshgrass1 0.20045,50.819,1,Wilmington,1,Cut 6,3,UWLM,10/30/2017 23:59:59,,eshgrass1 0.204241667,50.764325,1,Friston,1,Cut 6,3,UFRS,10/31/2017 23:59:59,,eshgrass1 Sadly the Python script from your GitHub has no readily-available version information but, from what I can see in your GitHub, the script has not changed since I downloaded it. Any help you can give will be most gratefully received. Kind regards, Jonathan
... View more
11-02-2017
03:22 AM
|
0
|
4
|
1075
|
POST
|
Thanks, Craig. I am indeed using the latest scripts, at least they were the latest when I double-checked last week. I’ll test again tomorrow and provide exact details of what I observe and the input data. Kind Regards, JG.
... View more
11-01-2017
12:31 PM
|
0
|
0
|
1075
|
POST
|
Thanks, Craig. But according to the Issue on GitHub it doesn’t even import basic fields like DueDate - which would surely be needed for everyday use in a use case where Assignments need to be batch imported from almost any other system... I take your point about not supporting migration - we’ve already accepted this can’t be done - but if we can’t import planned Assignments in any way so they are usable, my Client will have to abandon Workforce and build a bespoke system instead. Kind Regards, Jonathan.
... View more
11-01-2017
11:46 AM
|
0
|
8
|
1075
|
POST
|
When I export using this command: sudo python export_assignments_to_csv.py -outCSV "/home/pi/arcgis/exported_assignments.csv" -u "[redacted]" -p "[redacted]" -url "https:[redacted]arcgis" -pid "[redacted]" -logFile "/home/pi/arcgis/log.txt" -dateFormat "%m/%d/%Y %H:%M:%S" -timezone "US/Eastern" ... the following fields are blank in my output CSV file: assignmentType workOrderID dueDate workerId GlobalID There perhaps would be others but this is a test project designed to allow verification of field contents prior to importing large amounts of data as part of an AGL>Enterprise migration - and so these assignments have no progress-driven fields yet. I am wondering if these field values are stored differently in Enterprise Workforce? Grateful as ever for your help, guys... JG PS Just noticed this GitHub Issue refers to a similar problem: https://github.com/Esri/workforce-scripts/issues/11 - is there any news on this since July please?
... View more
10-23-2017
03:47 AM
|
0
|
2
|
538
|
POST
|
Hi Craig. Thanks for your reply. Yes, I’d noticed the coded type values: I have created dummy assignments containing each type with the type name as text in the description. As you note, the same issue arises with Workers but I have included all the variations in dummy assignments similarly. (This Project only has one Dispatcher.) Exporting these dummy assignments using the download to CSV script, then inspecting the CSV reveals the correlation between keys and values, so I can then search and replace in my input file with ease. Regarding the Status field... the documentation for the create_assignments_from_csv script does not mention Status as one of the available fields. What column header text must I use? The code in the create_assignments_from_csv.py script which handles passed parameters from the script invocation shows this: if __name__ == "__main__": # Get all of the commandline arguments parser = argparse.ArgumentParser("Add Assignments to Workforce Project") parser.add_argument('-u', dest='username', help="The username to authenticate with", required=True) parser.add_argument('-p', dest='password', help="The password to authenticate with", required=True) parser.add_argument('-url', dest='org_url', help="The url of the org/portal to use", required=True) # Parameters for workforce parser.add_argument('-pid', dest='projectId', help="The id of the project to add assignments to", required=True) parser.add_argument('-xField', dest='xField', help="The field that contains the x SHAPE information", required=True) parser.add_argument('-yField', dest='yField', help="The field that contains the y SHAPE information", required=True) parser.add_argument('-assignmentTypeField', dest='assignmentTypeField', help="The field that contains the assignmentType", required=True) parser.add_argument('-locationField', dest='locationField', help="The field that contains the location", required=True) parser.add_argument('-dispatcherIdField', dest='dispatcherIdField', help="The field that contains the dispatcherId") parser.add_argument('-descriptionField', dest='descriptionField', help="The field that contains the description") parser.add_argument('-priorityField', dest='priorityField', help="The field that contains the priority") parser.add_argument('-workOrderIdField', dest='workOrderIdField', help="The field that contains the workOrderId") parser.add_argument('-dueDateField', dest='dueDateField', help="The field that contains the dispatcherId") parser.add_argument('-attachmentFileField', dest='attachmentFileField', help="The field that contains the file path to the attachment to upload") parser.add_argument('-workerField', dest='workerField', help="The field that contains the workers username") parser.add_argument('-dateFormat', dest='dateFormat', default=r"%m/%d/%Y %H:%M:%S", help="The format to use for the date (eg. '%m/%d/%Y %H:%M:%S'") parser.add_argument('-timezone', dest='timezone', default="UTC", help="The timezone for the assignments") parser.add_argument('-csvFile', dest='csvFile', help="The path/name of the csv file to read") parser.add_argument('-wkid', dest='wkid', help='The wkid that the x,y values are use', type=int, default=4326) parser.add_argument('-logFile', dest='logFile', help='The log file to use', required=True) args = parser.parse_args() ... so I don't see how I can ever pass to the script which fieldname to use for the status? Much obliged. JG
... View more
10-20-2017
10:44 PM
|
0
|
10
|
1075
|
POST
|
I look after Workforce for an Enterprise Client organisation. They have just procured an on-prem instance of ArcGIS and I am migrating the Assignments from the old (ArcGIS Online Workforce) to new (private Workforce) instance. I have created a new Project, set up the required Assignment Types and given the Users the right Roles. I have exported all the Assignments from the old instance using the Python standalone script export_assignments_to_csv. I am editing the produced CSV file to make it compatible with the create_assignments_from_csv Python standalone script so that I can use this to upload the Assignments from the ArcGIS Online to the private Workforce... I have a bunch of Status field entries in my export, which I imagine reflect the Completed/In Progress/Paused etc status of each task - but the create_assignments documentation does not say that I can import these. Please advise how I can import the status fields? Or... is there a better way to achieve what I'm trying to do? Thanks so much in advance for your help. Jonathan
... View more
10-19-2017
04:33 AM
|
0
|
12
|
2050
|
POST
|
Hi. Failed to make head nor tail of the REST endpoint so am unable to verify if the data all appear in there. Please advise what the constraints are for Notes fields - in terms of maximum length, characters used etc - for use with the standalone scripts. I have previously seen an odd character (an I with acute accent) crash the download to csv script, and I'm starting to think my current problem might be due to Notes field length after all. A Notes-related suggestion: As a Project Owner, I want to have a filter allowing Dispatchers to view all Assignments which have a Notes field containing data, so that they can easily see any exceptions reported by site personnel. Kind regards, Jonathan
... View more
09-26-2017
12:01 AM
|
0
|
2
|
789
|
POST
|
Hi there. "terminal" in the case of Windows means "Command Prompt" (I'm guessing you're using Windows because you mentioned Anaconda - which I know is a Windows Python distribution). How to access it depends on your precise Windows version, but these steps will probably work: 1. Click Start 2. Type 'command prompt' (without the quotes) 3. Click the Command Prompt icon which appears. Note that, for certain operations, you may need to access the Command Prompt as Administrator. In this case, replace step 3 above with: 3. Right-click the Command Prompt icon which appears and choose 'Run as Administrator', then click 'Yes'. In certain cases you may be offered a 'Command Prompt as Admin' icon - in which case you can click this instead Hope this helps! Jonathan
... View more
08-30-2017
11:58 PM
|
0
|
0
|
1839
|
POST
|
Awesome – thanks so much for this. Kind regards, Jonathan
... View more
08-29-2017
08:48 AM
|
0
|
0
|
789
|
POST
|
Thanks, Craig. Not sure where the "service URL page" is but I'll investigate... The command line parameters I specify are shown in the bash script extract earlier in this thread. Kind regards, JG
... View more
08-29-2017
05:56 AM
|
0
|
2
|
789
|
POST
|
A thought just occurred to me... If the teams were able to both log in to the same account (as a single Worker), then the Assignments would be available for either of them to complete, right? A tweak to your backend would be needed, Craig - because the location tracking showing Worker locations in the Dispatcher portal seems to only show the last-logged-in mobile device if you log more than one in. Perhaps it could show the location of all the Workers added in to that account. I guess there could be financial reasons why this might not be desirable, though Hope this helps. J
... View more
08-29-2017
05:42 AM
|
0
|
0
|
1677
|
Title | Kudos | Posted |
---|---|---|
1 | 08-18-2017 02:42 AM | |
1 | 08-18-2017 01:28 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|