Issue 1:
Checklist

Celery report

software -> celery:4.2.0rc4 (windowlicker) kombu:4.2.1 py:3.6.5

billiard:3.5.0.3 py-amqp:2.3.2

platform -> system:Linux arch:64bit, ELF imp:CPython

loader -> celery.loaders.app.AppLoader

settings -> transport:amqp results:redis://redis/0

broker_url: 'amqp://user:********@rabbitmq:5672/test'

result_backend: 'redis://redis/0'

Steps to reproduce

When trying to create workflows which are started within a task like this:

#app.py
@app.task
def add(x, y):
return x + y

@app.task
def kickstart():
test_chain = (
add.s(1, 1) |
add.s(2) |
group(
add.s(3),
add.s(4)
)
)
result = test_chain()
return result

one cannot build a graph out of the result of the kickstart task:

>>> import app
>>> res = app.kickstart.delay()
>>> res.graph

A TypeError: unhashable type: 'GroupResult' is raised

Expected behavior

A graph should be constructed.

Actual behavior

A TypeError: unhashable type: 'GroupResult' is raised:

KeyError Traceback (most recent call last)
~/.local/share/virtualenvs/project-cdmlHYK5/lib/python3.6/site-packages/kombu/utils/objects.py in __get__(self, obj, type)
41 try:
---> 42 return obj.__dict__[self.__name__]
43 except KeyError:

KeyError: 'graph'

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last)
<ipython-input-3-dd95ac617ced> in <module>()
----> 1 res.graph

~/.local/share/virtualenvs/project-cdmlHYK5/lib/python3.6/site-packages/kombu/utils/objects.py in __get__(self, obj, type)
42 return obj.__dict__[self.__name__]
43 except KeyError:
---> 44 value = obj.__dict__[self.__name__] = self.__get(obj)
45 return value
46

/src/celery/result.py in graph(self)
387 @cached_property
388 def graph(self):
--> 389 return self.build_graph()
390
391 @property

/src/celery/result.py in build_graph(self, intermediate, formatter)
342 )
343 for parent, node in self.iterdeps(intermediate=intermediate):
--> 344 graph.add_arc(node)
345 if parent:
346 graph.add_edge(parent, node)

/src/celery/utils/graph.py in add_arc(self, obj)
54 def add_arc(self, obj):
55 """Add an object to the graph."""
---> 56 self.adjacent.setdefault(obj, [])
57
58 def add_edge(self, A, B):

TypeError: unhashable type: 'GroupResult'```

I believe this is because the class `GroupResult` does not implements a `__hash__` method like the `AsyncResult` class: https://github.com/celery/celery/blob/master/celery/result.py#L353
We should probably implement `__hash__` and `__str__`.

Issue 2:
Version: celery==4.1.0

$ celery -A poc worker --loglevel=info

-------------- celery@dudepro.local v4.1.0 (latentcall)
---- **** -----
--- * *** * -- Darwin-16.7.0-x86_64-i386-64bit 2018-05-16 17:42:08
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: poc:0x10287fc18
- ** ---------- .> transport: redis://localhost:6379/0
- ** ---------- .> results: redis://localhost:6379/0
- *** --- * --- .> concurrency: 12 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery

[tasks]
. poc.add

Celery worker runs fine, issue seems to be when the graph is built with build_graph().

Traceback (most recent call last):
File "/Users/user/.pyenv/versions/3.6.1/envs/3.6.1-celery-poc/lib/python3.6/site-packages/kombu/utils/objects.py", line 42, in __get__
return obj.__dict__[self.__name__]
KeyError: 'graph'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "poc.py", line 33, in <module>
root.graph.to_dot(fh)
File "/Users/user/.pyenv/versions/3.6.1/envs/3.6.1-celery-poc/lib/python3.6/site-packages/kombu/utils/objects.py", line 44, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "/Users/user/.pyenv/versions/3.6.1/envs/3.6.1-celery-poc/lib/python3.6/site-packages/celery/result.py", line 354, in graph
return self.build_graph()
File "/Users/user/.pyenv/versions/3.6.1/envs/3.6.1-celery-poc/lib/python3.6/site-packages/celery/result.py", line 314, in build_graph
graph.add_arc(node)
File "/Users/user/.pyenv/versions/3.6.1/envs/3.6.1-celery-poc/lib/python3.6/site-packages/celery/utils/graph.py", line 53, in add_arc
self.adjacent.setdefault(obj, [])
TypeError: unhashable type: 'GroupResult'

Steps to reproduce

import celery
from celery.canvas import group, chain

app = celery.Celery('poc')

app.conf.update(
task_serializer='json',
accept_content=['json'],
result_serializer='json',
enable_utc=True,
broker_url = 'redis://localhost:6379/0',
result_backend = 'redis://localhost:6379/0'
)

@app.task
def add(x, y):
return x + y

if __name__ == '__main__':

res = chain(add.si(1,1), group(add.si(2,2), add.si(3,3), add.si(4,4)))()
res.get()

# Find root result of graph
root = res.parent
while root.parent is not None:
root = root.parent

with open('graph.dot', 'w') as fh:
root.graph.to_dot(fh)

Expected behavior

Generate the dotfile as expected by transforming each list item task id into a node entity with a corresponding arc for the graph.

Actual behavior

Error shown above.

Disclaimer: I am brand new to celery.