Workforce migrate_assignments.py

1541
12
Jump to solution
12-28-2020 12:02 PM
JayHodny
Occasional Contributor III

Hello. I am trying to use the 'migrate_assignments' script to move assignment data from Classic Workforce projects to new Workforce projects in ArcGIS for Enterprise (10.8.1 with Workforce patch installed).  I have already used the 'migrate' utility in the Workforce web app dashboard to create new Workforce projects from the classic ones.  I am using ArcGIS Pro 2.7.0 which now has ArcGIS for Python 1.8.3.  I am using the 'migrate assignment only' command prompt provided in a blog dated August 31, 2020 (Migrate a Classic Workforce project (esri.com).

From the blog: python migrate_assignments.py -u <username> -p <password> -org https://<org>.maps.arcgis.com -classic-project-id <project-item-id> -new-project-id <new-project-fs-item-id>

I am running the script from the python shell in Pro.  Regardless of the command line settings, I receive a syntax error.  I place double quotes around the parameters instead of the < >.

python drive:\folder\folder\migrate_assignments.py -u "username" -p "password" -org "https://webadaptor.cityofnewarkde.us/portal" -classic-project-id 5c792f3583e44a6b910076d0d7f04628 -new-project-id 766c82cff9464341850ce625c6e99a76

I could not find a way to download the script directly from GitHub.  Rather, I had to copy the code and paste it into Notepad to create the migrate_assignments.py.

I have tried many iterations when it comes to placing the double quotes around the parameters.  My lack of experience is evident here.  The user has admin privileges.

I am at a loss as to why this script is not running, or as to what operator error is getting in the way.  Any help would be appreciated.

0 Kudos
1 Solution

Accepted Solutions
JayHodny
Occasional Contributor III

Hi Aaron,

We continued to run into an error when running the script.  The error was stating 'assignmentRead was not listed in the table' (or something to this effect).  After spending considerable time in trial and error in the command line settings, we realized the Python code specified "assignmentRead," while the field in the classic Workforce assignment feature service was named "assignmentread."  In our copy of the Python script, we edited the field name to all lower case and the script ran successfully.

Thanks again for your help,

Jay

View solution in original post

0 Kudos
12 Replies
by Anonymous User
Not applicable

@JayHodny

You can directly download it from Github using the "Code" button and choose "Download Zip".

AaronPulver_0-1609185970720.png

You need to run the script from the command-line not from the built-in Python Interpreter in ArcGIS Pro. So open "Python Command Prompt" from inside the ArcGIS folder. This will activate the correct conda environment for you.

Screen Shot 2020-12-28 at 3.09.17 PM.png

Then run the script there (after putting in all the parameters):

Screen Shot 2020-12-28 at 3.13.51 PM.png

0 Kudos
JayHodny
Occasional Contributor III

Hi Aaron,

Good grief, how did I miss the download section?...sigh.......OK, let me give this a try.  And thank you.

Regards,

Jay

0 Kudos
JayHodny
Occasional Contributor III

Hi Aaron,

We continued to run into an error when running the script.  The error was stating 'assignmentRead was not listed in the table' (or something to this effect).  After spending considerable time in trial and error in the command line settings, we realized the Python code specified "assignmentRead," while the field in the classic Workforce assignment feature service was named "assignmentread."  In our copy of the Python script, we edited the field name to all lower case and the script ran successfully.

Thanks again for your help,

Jay

0 Kudos
PLadd
by
Occasional Contributor III

Maybe somebody on this thread can help.  When running "conda env create --file environment.yml" from the instructions on this page, I get a pip error and the code stops running.  Having no experience with Python but desperately wanting to migrate my project's assignments, I need to resolve this problem that ESRI's code has created for me. 

Has anybody encountered a pip error when running this or know how to overcome a pip issue?

Here's what the error looks like:

++++++++++++++++++++++

Pip subprocess error:
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
error in pypng setup command: use_2to3 is invalid.
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

++++++++++++++++++++++

Thanks.

0 Kudos
by Anonymous User
Not applicable

@PLadd 

What operating system are you using for this?

0 Kudos
PLadd
by
Occasional Contributor III

Thanks for the quick response - Windows 10.

0 Kudos
PLadd
by
Occasional Contributor III

UPDATE: Have some further info.  Tried using the command below after landing on this page  and this page from google search of the pip error: 

pip install setuptools==58.0.3

But still getting the error.

0 Kudos
by Anonymous User
Not applicable

@PLaddin the environment.yml file at the bottom, there is a dependency called pypng. Try changing that one line from:

- pypng==0.0.18

to

- pypng==0.0.21

This should resolve the issue by upgrading that library. I tested this fix on a Windows 10 machine. I'll push up a fix to the repo later after I verify it doesn't break any of the notebooks that use that library.

PLadd
by
Occasional Contributor III

Whoa!  Thank you so much for picking out that minor issue and taking the time to share the correction with me.  Such a frustrating problem and such a simple solution.  Again many thanks.

0 Kudos