Watch the live stream:
Watch on YouTube
About the show
Sponsored by Datadog: pythonbytes.fm/datadog
Special guest: Brian Skinn (Twitter | Github)
Michael #1: OpenBB wants to be an open source challenger to Bloomberg Terminal
- OpenBB Terminal provides a modern Python-based integrated environment for investment research, that allows an average joe retail trader to leverage state-of-the-art Data Science and Machine Learning technologies.
- As a modern Python-based environment, OpenBBTerminal opens access to numerous Python data libraries in
- Data Science (Pandas, Numpy, Scipy, Jupyter)
- Machine Learning (Pytorch, Tensorflow, Sklearn, Flair)
- Data Acquisition (Beautiful Soup, and numerous third-party APIs)
- They have a discord community too
- BTW, seem to be a successful open source project: OpenBB Raises $8.5M in Seed Round Funding Following Open Source Project Gamestonk Terminal's Success
- Great graphics / gallery here.
- Way more affordable than the $1,900/mo/user for the Bloomberg Terminal
Brian #2: Python f-strings
- https://fstring.help
- Florian Bruhin
- Quick overview of cool features of f-strings, made with Jupyter
- Python f-strings Are More Powerful Than You Might Think
- Martin Heinz
- More verbose discussion of f-strings
- Both are great to up your string formatting game.
Brian S. #3: pyproject.toml and PEP 621 Support in setuptools
- PEP 621: “Storing project metadata in pyproject.toml”
- Authors: Brett Cannon, Dustin Ingram, Paul Ganssle, Pradyun Gedam, Sébastien Eustace, Thomas Kluyver, Tzu-ping Chung (Jun-Oct 2020)
- Covers build-tool-independent fields (name, version, description, readme, authors, etc.)
- Various tools had already implemented pyproject.toml support, but not setuptools
- Including: Flit, Hatch, PDM, Trampolim, and Whey (h/t: Scikit-HEP)
- Not Poetry yet, though it's under discussion
- setuptools support had been discussed pretty extensively, and had been included on the PSF’s list of fundable packaging improvements
- Initial experimental implementation spearheaded by Anderson Bravalheri, recently completed
- Seeking testing and bug reports from the community (Discuss thread)
- I tried it on one of my projects — it mostly worked, but revealed a bug that Anderson fixed super-quick (proper handling of a dynamic long_description, defined in setup.py)
- Related tools (all early-stage/experimental AFAIK)
- ini2toml (Anderson Bravalheri) — Can convert setup.cfg (which is in INI format) to pyproject.toml
- Mostly worked well for me, though I had to manually fix a couple things, most of which were due to limitations of the INI format
- validate-pyproject (Anderson Bravalheri) — Automated pyproject.toml checks
- pyproject-fmt (Bernát Gábor) — Autoformatter for pyproject.toml
- Don’t forget to use it with build, instead of via a python setup.py invocation!
- $ pip install build
$ python -m build
- Will also want to constrain your setuptools version in the build-backend.requires key of pyproject.toml (you are using PEP517/518, right??)
Michael #4: JSON Web Tokens @ jwt.io
- JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.
- Basically a visualizer and debugger for JWTs
- Enter an encoded token
- Select a decryption algorithm
- See the payload data
- verify the signature
- List of libraries, grouped by language
Brian #5: Autocorrect and other Git Tricks
- Waylon Walker
- Use `git config --global help.autocorrect 10` to have git automatically run the command you meant in 1 second. The `10` is 10 x 1/10 of a second. So `50` for 5 seconds, etc.
- Automatically set upstream branch if it’s not there
- git config --global push.default current
- You may NOT want to do this if you are not careful with your branches.
- From https://stackoverflow.com/a/22933955
- git commit -a
- Automatically “add” all changed and deleted files, but not untracked files.
- From https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--a
- Now most of my interactions with git CLI, especially for quick changes, is:
$ git checkout main
$ git pull
$ git checkout -b okken_something
$ git commit -a -m 'quick message'
$ git push
- With these working, with autocorrect
$ git chkout main
$ git pll
$ git comit -a -m 'quick message'
$ git psh
Brian S. #6: jupyter-tempvars
- Jupyter notebooks are great, and the global namespace of the Python kernel backend makes it super easy to flow analysis from one cell to another
- BUT, that global namespace also makes it super easy to footgun, when variables leak into/out of a cell when you don’t want them to
- jupyter-tempvars notebook extension
- Built on top of the tempvars library, which defines a TempVars context manager for handling temporary variables
- When you create a TempVars context manager, you provide it patterns for variable names to treat as temporary
- In its simplest form, TempVars (1) clears matching variables from the namespace on entering the context, and then (2) clears them again upon exiting the context, and restoring their prior values, if any
- TempVars works great, but it’s cumbersome and distracting to manually include it in every notebook cell where it’s needed
- With jupyter-tempvars, you instead apply tags with a specific format to notebook cells, and the extension automatically wraps each cell’s code in a TempVars context before execution
- Javascript adapted from existing extensions
- Patching CodeCell.execute, from the jupyter_contrib_nbextensions ‘Execution Dependencies’ extension, to enclose the cell code with the context manager
- Listening for the ‘kernel ready’ event, from [jupyter-black](https://github.com/drillan/jupyter-black/blob/d197945508a9d2879f2e2cc99cafe0cedf034cf2/kernel_exec_on_cell.js#L347-L350), to import the [TempVars](https://github.com/bskinn/jupyter-tempvars/blob/491babaca4f48c8d453ce4598ac12aa6c5323181/src/jupyter_tempvars/extension/jupyter_tempvars.js#L42-L46) context manager upon kernel (re)start
- See the README (with animated GIFs!) for installation and usage instructions
- It’s on PyPI: $ pip install jupyter-tempvars
- And, I made a shortcut install script for it: $ jupyter-tempvars install && jupyter-tempvars enable
- Please try it out, find/report bugs, and suggest features!
- Future work
- Publish to conda-forge (definitely)
- Adapt to JupyterLab, VS Code, etc. (pending interest)
Extras
Brian:
- Ok. Python issues are now on GitHub. Seriously. See for yourself.
- Lorem Ipsum is more interesting than I realized.
- O RLY Cover Generator
- Example:
Michael:
- New course: Secure APIs with FastAPI and the Microsoft Identity Platform
- Pyenv Virtualenv for Windows (Sorta'ish)
- Hipster Ipsum
Brian S.:
- PSF staff is expanding
- PSF hiring an Infrastructure Engineer
- Link now 404s, perhaps they’ve made their hire?
- Last year’s hire of the Packaging Project Manager (Shamika Mohanan)
- Steering Council supports PSF hiring a second developer-in-residence
- PSF has chosen its new Executive Director: Deb Nicholson!
- PyOhio 2022 Call for Proposals is open
- Teaser tweet for performance improvements to pydantic
Jokes:
https://twitter.com/CaNerdIan/status/1512628780212396036
https://www.reddit.com/r/ProgrammerHumor/comments/tuh06y/i_guess_we_all_have_been_there/
https://twitter.com/PR0GRAMMERHUM0R/status/1507613349625966599