Optimally Creating and Assigning Work Orders Based on Routes

Open
#99 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
jupyter-notebook, python
Domain
tooling

Research direction

Start with the “Optimally Creating and Assigning Work Orders Based on Routes” notebook and run the shown worker-assignment cell with representative route and worker data. Check whether removing a worker causes later iterations or assignment creation to fail, and consider the issue done when the notebook consistently creates the expected assignments without an empty-worker error.

Written by the indexing model from the issue text.

Description

Hello,
In the 'Optimally Creating and Assigning Work Orders Based on Routes' notebook there is the following code:

assignments_to_add = []
for _, row in routes.iterrows():
    worker = random.choice(workers)
    workers.remove(worker)
    route_stops = stops.loc[(stops['RouteName'] == row["RouteName"]) & stops['globalid'].notnull()]
    for _, stop in route_stops.iterrows():
        assignments_to_add.append(workforce.Assignment(
            project,
            assignment_type="Inspection",
            location=stop["name"],
            status="assigned",
            worker=worker,
            assigned_date=datetime.now(),
            due_date=stop["DepartTime"],
            geometry=stop["SHAPE"]
        ))
assignments = project.assignments.batch_add(assignments_to_add)

I think the line workers.remove(worker) should be removed because then in assignments_to_add.append() the worker=worker will give an error of empty list. Am I wrong?

Thanks

Dominant language
Jupyter Notebook
Stars
85
Forks
62
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Esri/workforce-scripts

All issues in Esri/workforce-scripts

Similar issues

More DevTools issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.