Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Python と Docker で mypy Playground を開発した話

1,250 views

Published on

PyCon mini Osaka 2018 https://osaka.pycon.jp

Published in: Software
  • Be the first to comment

Python と Docker で mypy Playground を開発した話

  1. 1. Python Docker mypy Playground Yusuke Miyazaki @ymyzk PyCon mini Osaka 2018 2018/5/19 Grand Front Osaka Development of mypy Playground with Python and Docker
  2. 2. • / @ymyzk • @ / Indeed • Python 6 + / PyCon JP / … • ymyzk.com
  3. 3. • : → (2 ) → ( ) • Python Boot Camp in • IT CAMPHOR- ( )
  4. 4. Python ? 
 
 Python Docker 
 mypy Playground
  5. 5. • • mypy Playground • Python + Docker mypy • •
  6. 6. mypy Playground
  7. 7. mypy ? 🙋
  8. 8. mypy ? 🙋
  9. 9. mypy • Python • PEP 484 / 526 • CLI def greeting(name: str) -> str: return f"Hello, {name}!!" greeting("Taro") greeting(123) # error: Argument 1 to "greeting" has # incompatible type "int"; expected "str"
  10. 10. mypy Playground: mypy-play.net • mypy Web • • mypy • • Gist
  11. 11. mypy Playground: URL HERE
  12. 12. mypy Playground • mypy • /tmp/test1.py • • mypy typeshed
  13. 13. : • • : The Go Playground / Rust Playground / Scastie (Scala) • • : Wandbox • : ymyzk/awesome-playgrounds
  14. 14. mypy Playground 
 
 
 UI 
 

  15. 15. 
 
 
 UI 
 
 Ace Bootstrap Bottle Docker
  16. 16. • • CPU
  17. 17. • • … • • • import •
  18. 18. Python + Docker mypy
  19. 19. Docker ? "
  20. 20. Docker • • : jail / LXC / systemd-nspawn • • Linux ( cgroups) •
  21. 21. Docker • • • Docker Hub • • Docker • Docker
  22. 22. Python Docker • Docker Engine API HTTP API • CLI docker API • Python Docker docker-py
  23. 23. • CLI • docker-py Python Docker $ docker run ubuntu echo Hello Osaka! import docker client = docker.from_env()
 client.containers.run("ubuntu", "echo Hello Osaka!")
  24. 24. mypy 1. mypy Docker 2. mypy 3.
  25. 25. Docker # typed-ast manylinux1 
 FROM python:3.6 RUN pip install mypy # root USER nobody CMD ["mypy"]
  26. 26. c = client.containers.create( "ymyzk/mypy-playground:sandbox", command="mypy main.py", network_mode="none", # mem_limit="128m", # pids_limit=32, cap_drop="ALL", security_opt=["no-new-privileges"])
  27. 27. # tar (Docker API ) tarball = create_archive(source) c.put_archive("/tmp", tarball)# c.start() # mypy exit_code = c.wait() # # stdout = c.logs(stdout=True, stderr=False).decode("utf-8") stderr = c.logs(stdout=False, stderr=True).decode("utf-8") c.remove()
  28. 28. • Docker mypy • • ? • :
  29. 29. Docker in Docker (dind) • Docker Docker • Docker 
 Docker Docker 

  30. 30. Docker in Docker • Docker • Docker • Docker
  31. 31. Docker in Docker • vfs 
 • 
 dind
  32. 32. mypy Playground • I/O • mypy • mypy • WSGI •
  33. 33. mypy Playground with asyncio • Bottle Tornado • Docker asyncio aiodocker • aiodocker docker-py
  34. 34. • mypy Playground • • typeshed / PEP 561 • Facebook Pyre • : / dmypy
  35. 35. • Python + Docker mypy Playground (mypy-play.net) • Web Python • Docker • Twitter: @mypy_playground / GitHub: ymyzk/mypy-playground • !!

×