All Posts By

tremble

Upgrade Python to support Django 2.0

Upgrading Python To Support Django 2.0

By Agile, Development, DevOps, Django, Python

Across the land, there are many developers, dev ops, and software delivery managers are terrified of the big move from Python 2.7 to Python 3.6 (at the time of writing this).  You can see all of the versions from the beginning of time.    I am going to walk you through why it is happening, how to plan, and more importantly, how to upgrade your infrastructure in a systematic manner.

Assumptions:

  • There are multiple developers on the team
  • There are multiple Django instances in your organization

Why move? Django

The answer is pretty easy… Django, the core web platform programming framework associated with the Python  programming language won’t support future releases in Python 2.7 any more. In fact, the Django 1.11.x series is the last to support Python 2.7.

Django 2.0 supports Python 3.4, 3.5, and 3.6. We highly recommend and only officially support the latest release of each series.

Note according to PEP 373, Python 2.7 is currently expected to remain supported by the core development team (receiving security updates and other bug fixes) until at least 2020 (10 years after its initial release, compared to the more typical support period of 18–24 months).

How to Plan?

When it comes time to plan for an event like this, it is important that you identify the critical components of your infrastructure.

Sample User Story

As a developer, would like to have a complete list of technical assets that use Python so I can generate an upgrade plan that reduces risk to the company.

Acceptance Criteria: Generate a list of the following assets which include:

  • Your Django platforms to include, dev, test, and production instances.
  • Other internal platforms ( AWS lambdas, small flask instances)
  • External/Internal libraries
  • Cronjob or schedule tasks running Python
  • Continuous Integration systems that build  (ie Jenkins)
  • Unit testing
  • QA regression testing scenarios
  • Code repositories
  • Your development team list (each one of them will have to complete upgrades)

Step 1 – Select Your First System

Pick your first system to do an end to end test.  If you only have one single platform of Django, then… you are done.  We recommend that you clone your dev instance for your first test.  If you don’t have a dev instance, stop reading this and make sure that you do have a dev, test and production version of your platform!

If you have multiple systems, we recommend that you select one that is much smaller in scope and will have as little impact on your operations as possible.

Sample User Story:

As a developer, I would like to select my first computing environment to upgrade Python on so I can minimize the impact on our operations.

Acceptance Criteria:

  • You selected one of the least impactful systems in your eco-systems
  • You clone a working environment that it identical to this instance.
  • You notify the team of what you are doing and discuss any impacts that your testing might have with them.

Step 2 – Start your documentation

If you have other people on the team, you will want to make sure that you can guide them along the path of upgrading their computing environments and be able to discuss problems that you had.

Sample User Story:

As a developer, I would like to document the upgrade process steps that  I took so I can help others on the team upgrade their computing environments to Python 3.6 with Django.

Acceptance Criteria:

  • Document your finding in confluence.

Step 3 – Review external dependencies

Not all pypi libraries are Python 3.6.3 compliant.  Many are only built on Python 2.7.  The good news however, is that most major libraries have been ported to 3.6.x.  The complete list of PyPi libraries per version is listed here.

Individual Library Inspections

As a developer, you can see the details of any pip installed library by calling this command: pip show LIBRARYNAME –verbose

Example:

(bytelion_env)~>pip show requests –verbose
Name: requests
Version: 2.13.0
Summary: Python HTTP for Humans.
Home-page: https://python-requests.org
Author: Kenneth Reitz
Author-email: me@kennethreitz.com
License: Apache 2.0
Location: /Users/terrancemacgregor/.virtualenvs/bytelion_env/lib/python2.7/site-packages
Requires:
Metadata-Version: 2.0
Installer: pip
Classifiers:
Development Status :: 5 – Production/Stable
Intended Audience :: Developers
Natural Language :: English
License :: OSI Approved :: Apache Software License
Programming Language :: Python
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy

Sample User Story

As a developer, I would like to know which PyPi libraries are not supported by my current system so I can determine a migration strategy.

Acceptance Criteria

  • List is generated and shared with the team
  • For each library that is not supported, identify an alternative.

 

Remember the 80/20 rule?

Many of the upgrades from 2.7 to 3.6 can be safely automated, some other changes (notably those associated with Unicode handling) may require careful consideration, and preferably robust automated regression test suites, to migrate effectively.

 

Upgrading Server Code

 

Programming Language :: Python

Here is a list of what some other people experienced:

https://www.calazan.com/upgrading-to-ubuntu-1604-python-36-and-django-111/

https://blog.thezerobit.com/2014/05/25/python-3-is-killing-python.html

Worst LPT Reddit Post Ever | How to get a raise… look for a new job

By Leadership

Hiring, training, and retaining people is perhaps one of the most validating experiences in life.  It is validating to the individual who took the risk to hire and the person being hired.  As an avid reader of Reddit, one of my favorite sections is the ‘Life Pro Tips.’ In LPT’s, “expert” advice across a variety of topics is given.  The following is by far the worst.

screen-shot-2017-09-13-at-11-53-58-amFull URL

Bad Comments

I am sure that the author’s point of view and the subsequent comments from disgruntled employees is correct based on their experiences, but there are so many more variables.  If you go through life seeking new employment when within a bad company, you are doing it right.  If you end up leaving good companies to get the next raise, you are making a galactic mistake.  Here are some of the comments that I thought were particularly bad.

  • “A smart person once told me,  ‘the best time to look for a new job is when you don’t need it.’ ”
    Stop. Understand your business and think five years out about how profitable you could make the company and do it.
  • “In most industries, especially IT, your biggest and best promotions will 90% of the time come from another company. That’s what I’ve learned, anyway.”
    Take time to understand what your value is to your employer.  You may be working in a business that doesn’t make money from your job, but they need it to function.  There may be some other businesses that need your job to make a lot of money so that they can pay you more.  Find out how you can help your company make money and do that!
  • “One thing that I have realized is that each job will always see you as you were when you applied. Think of your little cousin. They’re always going to be that little cousin no matter what happens. If you’re the fresh out of school new employee three years later they’ll still remember the fresh out of school.”
    Wrong.  You are a tiger and an ass kicker.  Don’t be a wimp.
  • “Speaking as someone who is in his early 30s and has been laid off twice. Company loyalty only exists to exploit you.”
    Victim speaks!  Just imagine if you, the reader needed to hire someone.  Are you now an exploiter?  Most likely not.

Positive Comments

I did find some sensible comments from level headed people.  As an employee, if there are mutual trust and respect with your employer, you should give absolutely everything you have to that job to make the company more respectful. Read books, look at trends, and think beyond your current role.  Track competitors, read about your clients, make suggestions.  Prepare and give talks.  Do not stop being a money generator for your company.  Not only will you make it impossible for your company not to give you a raise, but you will also be able to work yourself into a position of power and influence with some great people.  Those relationships last a lifetime.

  • “After you get your first job out of college: every six months have a one-on-one meeting with your supervisor. Talk about your progress within the company/agency/group, and voice your support for participation in projects or programs that would be beneficial to your career, or promotions. Let your supervisor know you are interested in challenges.”
    Right on.  Bring value and communicate. It is a win/win.  We do this every three months at Bytelion.
  • “That’s right, never stay in one place too long. Don’t form any lasting bonds, don’t preserve institutional knowledge, don’t let there be any stability in your life. You’re a shark, endlessly prowling, endlessly growing larger, cold as the ocean depths. Life is definitely better that way.”
    This is rough!  We don’t completely agree with this.. but we believe that building company culture is extremely important.
  • “I honestly completely disagree. A very wise CEO of mine once said, “don’t day trade your career.”
    This commenter is alluding to the fact that everyone is always looking for something better. In reality, you should find a decent company and stand fast. You will incur so many gains in compensation and experience (especially in a start-up)…
    If you ARE in a toxic environment, GET OUT. Everything is subjective.

Final Note

In many ways, working for someone is like being in a relationship.  You want your partner to be fun, hard working, exciting, and have some challenges. You don’t want your relationship to be exploitative, boring, easy, and too comfortable.  Selecting the right partner is tricky.  If you can find one worth keeping, making it work will be amazing for everyone.

 

 

Make Your Content More Compelling With Embedded Twitter Searches

By Development, Marketing, Tips & Tutorials, Tools

Twitter has made it easier and easier to select content out of their daily feed to help you track items are you interested in. For example, if you were interested in knowing what was happening in the twitter sphere of influence for new environmental projects like the Dakota Access Pipeline Protects, you could simply embed the search on your page like. The steps you need are to:

Step 1

Create a twitter account (if you don’t have one) and log in.

Step 2

Go to the widget page:  https://twitter.com/settings/widgets

Step 3

Select Create new search widget.

Search Widget

Simple Twitter Search Page

Step 4

Configure your widget.

Configure the widget according to the specifications you have set.

Configure the widget according to the specifications you have set.

Step 5

Copy text and paste example into your WordPress blog.  Similar to this.  See below.  And, that’s it! You now have content that is far more compelling with live data.