Python Bytes
Python Bytes
Aug 18, 2020
#195 Runtime type checking for Python type hints
33 min

Sponsored by us! Support our work through:

Michael #1: watchdog

  • via Prayson Daniel
  • Python API and shell utilities to monitor file system events.
  • Example:
    observer = Observer()
    observer.schedule(event_handler, path, recursive=True)
    observer.start()
  • Watchdog comes with an optional utility script called watchmedo
  • try $ watchmedo log and see what happens in that folder.
  • Why Watchdog? Compared to other similar libs

Brian #2: Status code 418

  • Thanks Andy Howe for the suggestion
  • Python 3.9 rc1 is out.
  • One nice enhancement that has made it into 3.9, a fix for http library missing HTTP status code 418 “I’m a teapot”.
  • https://bugs.python.org/issue39507
    • Title: http library missing HTTP status code 418 "I'm a teapot"
  • See also status code 418 is also supported by HTCPCP, Hyper Text Coffee Pot Control Protocol, https://tools.ietf.org/html/rfc2324
    • 418 I'm a teapot
Any attempt to brew coffee with a teapot should result in the error  code "418 I'm a teapot". The resulting entity body MAY be short and stout.
  • The only other unique HTCPCP code is 406
    • 406 Not Acceptable
… In HTCPCP, this response code MAY be returned if the operator of the coffee pot cannot comply with the Accept-Addition request. Unless the request was a HEAD request, the response SHOULD include an entity containing a list of available coffee additions.

Michael #3: pydantic’s new Validation decorator

  • via Andy Shapiro
  • Built-in type checking for any function via a decorator
  • easy to add for any public methods in a package
  • pydantic uses lots of cython under the hood so it should be fast....
  • The validate_arguments decorator allows the arguments passed to a function to be parsed and validated using the function's annotations before the function is called.
  • Under the hood this uses the same approach of model creation and initialization; it provides an extremely easy way to apply validation to your code with minimal boilerplate.
  • Example:
    from pydantic import validate_arguments, ValidationError

    @validate_arguments
    def repeat(s: str, count: int, *, separator: bytes = b'') -> bytes:
        b = s.encode()
        return separator.join(b for _ in range(count))

    a = repeat('hello', 3)
    print(a)
    #> b'hellohellohello'

    b = repeat('x', '4', separator=' ')
    print(b)
    #> b'x x x x'

    try:
        c = repeat('hello', 'wrong')
    except ValidationError as exc:
        print(exc)
        """
        1 validation error for Repeat
        count
          value is not a valid integer (type=type_error.integer)
        """

Brian #4: Building Python Extension Modules in Assembly

  • Anthony Shaw
  • From twitter announcement:
    • “After a series of highly questionable life decisions, my Python extension written in pure assembly is now on PyPI. https://pypi.org/project/pymult/ it required writing an Assembly extension for distutils, I also added GitHub Actions support so its running CI/CD and testing with pytest”.
  • A proof-of-concept to demonstrate how you can create a Python Extension in 100% assembly.
  • Demonstrates:
    • How to write a Python module in pure assembly
    • How to write a function in pure assembly and call it from Python with Python objects
    • How to call the C API to create a PyObject and parse PyTuple (arguments) into raw pointers
    • How to pass data back into Python
    • How to register a module from assembly
    • How to create a method definition in assembly
    • How to write back to the Python stack using the dynamic module loader
    • How to package a NASM/Assembly Python extension with distutils
  • The simple proof-of-concept function takes 2 parameters,
    >>> import pymult
    >>> pymult.multiply(2, 4)
    8  
  • May need a few more test cases:
    >>> pymult.multiply(2, 3)
    6
    >>> pymult.multiply(-2, -3)
    6
    >>> pymult.multiply(-2, 3)
    4294967290
  • Also, clearly Anthony has too much time on his hands. Just saying.

Michael #5: easy property

  • via Ruud van der Ham
  • The easy_property module, developed by me, offers a more intuitive way to define a Python property with getter, setter, deleter, getter_setter and documenter decorators.
  • Normally when you want to define a property that has a getter and a setter, you have to do something like
    Class Demo:
        def __init__(self, val):
            self.a = val
        @property
        def a(self):
            return self._a

        @a.setter
        def a(self, val):
            self._a = val
  • IMHO, the @a.setter is a rather ugly decorator, and hard to remember. And there's no way to not define the getter.
  • With the easy_property module, one can use the decorators
    • getter
    • setter
    • deleted
  • as in:
    Class Demo:
        def __init__(self, val):
            self.a = val
        @getter
        def a(self):
            return self._a
        @setter
        def a(self, val):
            self._a = val
        @deleter
        def a(self):
            print('delete')
            del self._a
  • In contrast with an ordinary property, the order of definition of getter, setter and deleter is not important. And it is even possible to define a setter only (without a getter), just in case.
  • With easy_property, you can even create a combined getter/setter decorator:
    Class Demo:
        def __init__(self, val):
            self.a = val
        @getter_setter
        def a(self, val=None):
            if val is None:
                return self._a
            self._a = val
  • Finally, it is possible to add a docstring to the property, with the @documenter decorator:
    Class Demo:
        def __init__(self, val):
            self.a = val
        @getter
        def a(self):
            return self._a
        @documenter:
        def a(self):
            return "this is the docstring of Demo.a"

Although this might not be always a good solution, I think in many cases this will make it easier and more intuitive to define properties.

Brian #6: Non Blocking Assertion Failures with pytest-check

  • Ryan Howard wrote an article about a project of mine on the TestProject blog.
  • I think it’s a first that someone else wrote an article about something I made. So that’s cool.
  • Most tests do the “check” part with assert statements.
  • The problem is assert stops after the first failure and you often want to check lots of stuff, and you want to see all the failures.
  • Ryan has a good example with checking web pages using selenium and a simple example of wanting to check both the content of an element on the page, and the url.
  • Cool use of pytest-check
  • See also:

Extras:

Brian

  • PSA: There are no capital letters in pytest, even if it begins a sentence.

Michael

Joke:

  • XKCD git - xkcd.com/1597
  • “I used to do low-level programming. Then a product I bought told me, "No assembly required." Since then, I've been coding in Python.” - From Rueven Lerner, Inspired by Anthony Shaw
Kubernetes Podcast from Google
Kubernetes Podcast from Google
Adam Glick and Craig Box
KubeCon NA 2020, with Stephen Augustus
Join us for all the news from KubeCon NA 2020, and a conversation with conference co-chair Stephen Augustus. Stephen is a Senior Open Source Engineer on the VMware Tanzu team, a chair of Kubernetes’ SIG Release, and a leader in many other parts of the project, past and present. Do you have something cool to share? Some questions? Let us know: * web: kubernetespodcast.com * mail: kubernetespodcast@google.com * twitter: @kubernetespod Chatter of the week * The kākāpō wins Bird of the Year * We’re off for 2 weeks. See you on December 8! News of the week * Cisco acquires Banzai Cloud * CNCF announces Cloud Native Survey 2020 results * Red Hat: New edge features, industrial AI/ML blueprint and AWS launch * CNCF End User Tech Radar for storage * New End User benefits * Envoy Mobile joins the CNCF * New sandbox projects * cert-manager * cdk8s * Kyverno * OpenKruise * Pravega * SchemaHero * Tinkerbell * k8ssandra from Datastax * Episode 98 with Sam Ramji * k0s from Mirantis * Solo.io announces Gloo Mesh Enterprise and rebrands products * Episode 55, with Idit Levine * Pinniped * Shipa launches Ketch * Kinvolk launches Headlamp * The SPIFFE book “Solving The Bottom Turtle” * Episode 45, with Andrew Jessup * Anthos Developer Sandbox * GKE ingress features * Ambassador Labs takes in $18m and launches v1.9 * Tanzu SQL: Postgres on Kubernetes * Lightning round: * Accurics extends Terrascan * AWS adds containers to Lightsail * Arrikto takes $10m in funding * Brobridge releases Gravity * CircleCI runner is GA * Cloud66 for agencies and multiple database support * Cloudflare Origin CA cert-manager plugin * Cloudical Vanillastack * Cloudify version 5.1 * Codefresh launches GitOps 2.0 features * Commvault backup-as-a-service * Diamanti Spektra 3.1 and customer portal * Dynatrace PurePath 4 * Elastisys Compliant Kubernetes * The Fairwinds Kubernetes Maturity Model * Garden takes “seed” funding * Gremlin adds soundproofing * Humio Operator * Instana adds observability tools on Kubernetes * Intuit runs TurboTax on Kubernetes * Kioxia announces a new storage offering * Kubecost adds features for monitoring outside a cluster * KubeMQ adds automatic network creation * Kubermatic updates KubeOne to v1.1 * Kubernative SINA * Kublr 1.19 * Lablup announced Backend.ai 20.09 RC * Magalix launches KubeAdvisor 2.0 * Mayadata launches Kubera Propel and Kubera Chaos * Mirantis adds extensions to Lens * Puppet Labs adds Relay to Puppet Enterprise * Reblaze announces Curiefense to add WAF to Envoy * Replicates wants to help you Troubleshoot * Styra adds new editions to DAS * Sysdig introduces Kubernetes-native network security (ZTNSK) and partners with IBM Cloud * TrilioVault for Kubernetes v2.0 * Zerto for Kubernetes * Google Open Source Live Kubernetes Links from the interview * KubeCon NA 2020 * Episode 117, with Constance Caramanolis * CNCF Twitch * SIG Friday: ping Stephen for the current link * Slack * CNCF Slack * Kubernetes Slack * Hallway Track * Kubernetes Podcast chat * CoreOS * CoreOS Tectonic * CoreOS acquired by Red Hat * Tectonic on Azure * SIG Azure * SIG Release * SIG PM (retired) * Kubernetes Enhancement Process * Receipts process KEP * Sidecar containers - KEP closed! * Production readiness review * Episode 10, with Josh Berkus and Tim Pepper * Release managers * Black Lives Matter announcement banner * Better announcements * Kubernetes Naming working group * Inclusive Naming project * Dan Kohn memorial * Stephen Augustus on Twitter and on the web
53 min
Streaming Audio: A Confluent podcast about Apache Kafka
Streaming Audio: A Confluent podcast about Apache Kafka
Confluent, original creators of Apache Kafka®
Multi-Tenancy in Apache Kafka ft. Anna Pozvner
Multi-tenancy has been quite the topic within the Apache Kafka® community. Anna Povzner, an engineer on the Confluent team, spends most of her time working on multi-tenancy in Kafka in Confluent Cloud. Anna kicks off the conversation with Tim Berglund (Senior Director of Developer Experience, Confluent) by explaining what multi-tenancy is, why it is worthy to be desired, and advantages over single-tenant architecture. By putting more applications and use cases on the same Kafka cluster instead of having a separate Kafka cluster for each individual application and use case, multi-tenancy helps minimize the costs of physical machines and also maintenance. She then switches gears to discuss quotas in Kafka. Quotas are essentially limits—you must set quotas for every tenant (or set up defaults) in Kafka. Anna says it’s always best to start with bandwidth quotas because they’re better understood. Stick around until the end as Anna gives us a sneak peek on what’s ahead for multi-tenant Kafka, including KIP-612, the addition of the connection rate quota, which will help protect brokers. EPISODE LINKS * Sharing is Caring: Toward Creating Self-Tuning Multi-Tenant Kafka (Anna Povzner, Confluent) Join the Confluent Community Slack * Learn more with Kafka tutorials, resources, and guides at Confluent Developer * Live demo: Kafka streaming in 10 minutes on Confluent Cloud * Use *60PDCAST* to get an additional $60 of free Confluent Cloud usage (details)
44 min
Software Defined Talk
Software Defined Talk
Software Defined Talk LLC
Episode 272: This time we’re doing it in green
This week we discuss IBM buying Instana, highlights from Kubecon and the rise of Substack. Plus, Coté updates us on his quest to live the iPad lifestyle. The Rundown IBM To Acquire Instana For Undisclosed Terms (https://www.nasdaq.com/articles/ibm-to-acquire-instana-for-undisclosed-terms-quick-facts-2020-11-18) Instana Crunch Base Overview (https://www.crunchbase.com/organization/instana) KubeCon Review Envoy Mobile Joins the CNCF (https://medium.com/@mike.schore/99aee4bdb32e) Open Source Web Engine Servo to be Hosted at Linux Foundation - The Linux Foundation (https://www.linuxfoundation.org/press-release/2020/11/open-source-web-engine-servo-to-be-hosted-at-linux-foundation/) Relevant to your Interests The Evolution of Cloud (https://greylock.com/jerry-chen-the-evolution-of-cloud/) 2020 State of DevOps Report | presented by Puppet, & CircleCi (https://puppet.com/resources/report/2020-state-of-devops-report/?mkt_tok=eyJpIjoiWldSbVpUbGtaVEZtWVRFMiIsInQiOiJhYWtBcEcxQ3Z2TitXcCtkbXJDZTBIbVcrb25qMEtTR1VvWXZNaDV2QmZEXC96ekJxZGxIRmxcL0JwaHdjN1FVYWMrUm9rRG8rYTE3QmozRlo4QU9IdFhvRWt3WUNvdDVvZWJSVmpLaFEzZnhNMllocGZNZUlUS0RmcVwvTDVZSEh3RSJ9) Amazon's Inferentia AI Chip Is Ready For Prime Time, Now Powers the Alexa Service (https://www.fool.com/investing/2020/11/12/amazons-inferentia-ai-chip-is-ready-for-prime-time/) FinOps Foundation launches Kubernetes Whitepaper with CNCF, adds vendor members, Densify, SoftwareOne, Virtasant and more... (https://www.finops.org/blog/finops-foundation-launches-kubernetes-whitepaper-with-cncf-adds-vendor-members-cloudcmx-densify-softwareone-and-virtasant/) Google Pay reimagined: pay, save, manage expenses and more (https://blog.google/products/google-pay/reimagined-pay-save-manage-expenses-and-more/?utm_source=newsletter&utm_medium=email&utm_campaign=newsletter_axioslogin&stream=top) New Zoom feature can alert room owners of possible Zoombombing disruptions (https://www.zdnet.com/article/new-zoom-feature-can-alert-room-owners-of-possible-zoombombing-disruptions/) Fast Facts Your Pa$$word doesn't matter (https://techcommunity.microsoft.com/t5/azure-active-directory-identity/your-pa-word-doesn-t-matter/ba-p/731984) 11 facts about real world container use (https://www.datadoghq.com/container-report/) Half of all containers are now managed by cloud provider and third-party registries (https://www.datadoghq.com/container-report/#10) Apple Apple to lower commissions for small businesses on App Store (https://www.axios.com/apple-to-lower-commissions-for-small-businesses-on-app-store-a385a49b-9558-411d-bd1b-6cb57f2d44cc.html) Safely open apps on your Mac (https://support.apple.com/en-us/HT202491?utm_source=newsletter&utm_medium=email&utm_campaign=newsletter_axioslogin&stream=top) Yeah, Apple’s M1 MacBook Pro is powerful, but it’s the battery life that will blow you away (https://techcrunch.com/2020/11/17/yeah-apples-m1-macbook-pro-is-powerful-but-its-the-battery-life-that-will-blow-you-away/) Mac users couldn’t launch apps this afternoon after Apple verification server issue (https://www.theverge.com/2020/11/12/21563092/apple-mac-apps-load-slow-big-sur-downloads-outage-down-issues) Nonsense Welcome to Slow Boring (https://www.slowboring.com/p/welcome-to-slow-boring) Zoom Is Temporarily Removing Its 40 Minute Limit on Video Calls for Thanksgiving Day (https://www.news18.com/news/tech/zoom-is-temporarily-removing-its-40-minute-limit-on-video-calls-for-thanksgiving-day-3083945.html) Sponsors strongDM — Manage and audit remote access to infrastructure. Start your free 14-day trial today at: strongdm.com/SDT (http://strongdm.com/SDT) Teleport provides consolidated access to all computing resources such as servers, Kubernetes clusters or internal applications across all environments. Watch a demo, download the free version, or sign up for cloud at goteleport.com (https://goteleport.com/) Listener Feedback Little Snitch (http://Little Snitch 4) from Jordy Mac users couldn’t launch apps this afternoon after Apple verification server issue (https://www.theverge.com/2020/11/12/21563092/apple-mac-apps-load-slow-big-sur-downloads-outage-down-issues) Conferences Mykel Alvis All Day DevOps Talk (https://youtu.be/cttjekzVEqU?t=1945) SDT news & hype Join us in Slack (http://www.softwaredefinedtalk.com/slack). Send your postal address to stickers@softwaredefinedtalk.com (mailto:stickers@softwaredefinedtalk.com) and we will send you free laptop stickers! Follow us on Twitch (https://www.twitch.tv/sdtpodcast), Twitter (https://twitter.com/softwaredeftalk), Instagram (https://www.instagram.com/softwaredefinedtalk/) and LinkedIn (https://www.linkedin.com/company/software-defined-talk/). Brandon built the Quick Concall iPhone App (https://itunes.apple.com/us/app/quick-concall/id1399948033?mt=8) and he wants you to buy it for $0.99. Use the code SDT to get $20 off Coté’s book, (https://leanpub.com/digitalwtf/c/sdt) Digital WTF (https://leanpub.com/digitalwtf/c/sdt), so $5 total. Become a sponsor of Software Defined Talk (https://www.softwaredefinedtalk.com/ads)! Recommendations Matt: Rewatching Veep (https://www.imdb.com/title/tt1759761/). Brandon: The Undoing (https://www.hbo.com/the-undoing?camp=GOOGLE%7cHTS_SEM%7cPID_p56310902692&keyword=the+undoing+hbo+show&utm_id=sa%7c71700000070858786%7c58700006239587173%7cp56310902692&utm_content=tun&gclid=Cj0KCQiA48j9BRC-ARIsAMQu3WSxjOpeoiBA6i3bBzeC-IL0JpPrwhoPrBOmtfTcNA37YokcAcnFo54aAtPnEALw_wcB&gclsrc=aw.ds) on HBO (https://www.hbo.com/the-undoing?camp=GOOGLE%7cHTS_SEM%7cPID_p56310902692&keyword=the+undoing+hbo+show&utm_id=sa%7c71700000070858786%7c58700006239587173%7cp56310902692&utm_content=tun&gclid=Cj0KCQiA48j9BRC-ARIsAMQu3WSxjOpeoiBA6i3bBzeC-IL0JpPrwhoPrBOmtfTcNA37YokcAcnFo54aAtPnEALw_wcB&gclsrc=aw.ds) and Serverless Data APIs (https://www.thecloudcast.net/2020/11/serverless-data-apis.html) from the Cloudcast Coté: Dithering (https://dithering.fm/)) podcast (https://dithering.fm/)) (https://dithering.fm/ (https://dithering.fm/)); Ted Laso. (https://tv.apple.com/show/umc.cmc.vtoh0mn0xn7t3c643xqonfzy?itscg=MC_20000&itsct=atvp_brand_omd&mttn3pid=a_google_adwords&mttnagencyid=1625&mttncc=US&mttnsiteid=143238&mttnsubad=OUS2019863_1-469980364686-c&mttnsubkw=106182847425_kwd-937070194980_rdMG7cVq_&mttnsubplmnt=) Photo Credit from Red Hat Container Coloring Book (https://developers.redhat.com/books/container-coloring-book-whos-afraid-big-bad-wolf) Photo Credit (https://unsplash.com/photos/wBzam0EPbXU)
1 hr 5 min
Azure DevOps Podcast
Azure DevOps Podcast
Jeffrey Palermo
Scott Nichols on the State of Azure - Part 2 - Episode 116
This episode is part 2 of the interview with Scott Nichols! Be sure to tune in to part 1 first before joining in on this episode’s conversation. Scott Nichols is a Sr. Cloud Solutions Architect, Scott works for the commercial enterprise division serving the west region. He is also the leader of the .NET and the Azure user groups in Boise, Idaho. He started his career in the IT profession in 1993 as a mainframe and web developer. Since then, he has served as a Lead Software Engineer/Solution Architect, a Software Development Engineering Manager, a Sr. Cloud Software Solution Architect, a Sr. Enterprise Solution Architect, and of course, most recently, a Sr. Cloud Solutions Architect at Microsoft since 2019. In this second part, the interview transitions from discussing the state of Azure and the Cloud industry into talking about how customers are modernizing their existing applications and infrastructure for Azure. Scott shares about infrastructure as code tools he sees as having the most traction right now, his recommendations for those looking to get their application into Azure, and what he sees as being the most successful pathways for his customers utilizing Azure infrastructure. Topics of Discussion: [:38] Be sure to visit AzureDevOps.Show for past episodes and show notes. [1:01] About The Azure DevOps Podcast and Jeffrey’s offer to speak at virtual user groups. [1:11] Clear Measure is hiring! Be sure to check out the link in the show notes. [1:33] Jeffrey welcomes Scott back to the podcast for part 2 and shares about this episode’s conversation. [2:06] The infrastructure as code tools Scott sees as having the most traction. [4:35] Does Scott have any customers that have used Azure Bicep yet? [4:56] How Scott thinks about Azure infrastructure and what he sees as being most successful with his customers. [7:42] For certain tweaks in the infrastructure, where does an ARM template work? [9:45] What is the mechanism in Azure that would know that the Powershell script has not been run yet or has already been run so that it doesn’t run it again? [11:07] A word from Azure DevOps Podcast’s sponsor: Clear Measure. [11:38] For people looking to get their application into Azure, what would Scott recommend their next steps be? [20:37] Jeffrey thanks Scott for joining the podcast and Scott offers some parting words of advice for developers. Mentioned in this Episode: Azure DevOps Clear Measure (Sponsor) .NET DevOps for Azure: A Developer's Guide to DevOps Architecture the Right Way, by Jeffrey Palermo — Available on Amazon! bit.ly/dotnetdevopsebook — Click here to download the .NET DevOps for Azure ebook! Jeffrey Palermo’s Youtube Jeffrey Palermo’s Twitter — Follow to stay informed about future events! The Azure DevOps Podcast’s Twitter: @AzureDevOpsShow Scott Nichols’ LinkedIn Scott Nichols’ Twitter @TheScottNichols Azure Architecture Center - Microsoft Amazon Web Services (AWS) Azure Architectures - Microsoft Docs Google Cloud (GCP) Microsoft Cloud Adoption Framework (CAF) Azure Bicep on GitHub .NET Conference 2020 Python Terraform Azure Resource Manager (ARM) CICD PowerShell HashiCorp Want to Learn More? Visit AzureDevOps.Show for show notes and additional episodes.
23 min
The Cloudcast
The Cloudcast
Cloudcast Media
eBPF & Cilium Cloud-native Networking
Dan Wendlandt (@danwendlandt, CEO/Co-Founder @Isovalent talks about the evolution of cloud networking, eBPF and Cilium for programmable infrastructure, and blurring the lines between networking, security and service-mesh.  *SHOW: *476 *SHOW SPONSOR LINKS:* * CloudAcademy -Build hands-on technical skills. Get measurable results.  * Get 50% of the monthly price of CloudAcademy by using code CLOUDCAST * Datadog Security Monitoring Homepage - Modern Monitoring and Analytics * Try Datadog yourself by starting a free, 14-day trial today. Listeners of this podcast will also receive a free Datadog T-shirt. * Learn more about Fauna: https://www.fauna.com/serverless * Try FaunaDB for Free: https://dashboard.fauna.com/accounts/register *CLOUD NEWS OF THE WEEK *- http://bit.ly/cloudcast-cnotw *PodCTL Podcast is Back (Enterprise Kubernetes) *- http://podctl.com *SHOW NOTES:* * Isovalent (homepage) * Cilium (homepage) * What is eBPF?  *Topic 1 *- Welcome to the show. We’ve been following your work for a while (Nicira, OpenShift networking, etc), but tell our audience a little bit about your background. *Topic 2* - A few years ago I wrote an article that said, “if you’re in networking, the #1 skill you should learn is Linux”. Why has there been so much shift from “traditional networking” to so many new capabilities being implemented in software, and specifically Linux? *Topic 3 *- Help us understand these two new concepts - eBPF and Cilium. It’s new packet filtering, it’s container networking, it’s multi-cluster networking, it can help with observability - lots going on here.  *Topic 4 *- What are some of the gaps in today’s networking/filtering/observability stacks that can improve with eBPF/Cilium?*   * *Topic 5 *- We’ve seen quite a few companies evolve from expertise in an open-source project to commercial offerings. What lessons have you learned from other companies that shape how Isovalent will both go-to-market and also engage with ecosystem partners?* * *Topic 6 *- What are some of the common use-cases or applications you see that highlight the value of the Isovalent stack?  *FEEDBACK?* * Email: show at thecloudcast dot net * Twitter: @thecloudcastnet
36 min
More episodes
Search
Clear search
Close search
Google apps
Main menu