Hi FME'er,
At this time of year - American Thanksgiving to be precise - the support team at Safe takes a couple of days on something we call "Demo Daze". It's like a mini-hackathon for us. Because of that, this question of the week is going to be a little shorter, and in fact, the question is really one I am asking you:
Have you upgraded all your v2.7 Python scripts to v3 yet?
Let's see why...
Question of the WeekActually, I was inspired to ask by a couple of questions on Python this week:
- Python Version Error: What are my options? (@bo)
- Python Startup Script: Why does it work on FME Desktop, but not Server? (@billybob)
As it turned out, neither issue was really related to Python, but what if they were? It got me wondering about Python versions.
Python 2.7If you weren't aware, Python v2 is being deprecated in favour of v3. In fact it's only 1 month, 2 days, 14 hours and 30 minutes away (and counting down...)
Why? Because it's older technology now, and contains a lot of security holes. Plus it relies on the Visual Studio 2008 (VS2008) runtime, which Microsoft no longer supports.
Is FME Ready?Yes, it is. We've been working on this for quite a while now. We use Python in various places in FME, and it's all been updated where necessary.
But, obviously, you can tie in Python with FME too, as an author. In previous versions of FME (say 2017, 2018), we supported both v2 and v3 of Python, using a compatibility setting in the Navigator window.
In FME 2019 we still supported v2 but it became an optional installation.
And if you do now try and make or edit a workspace set to be compatible with a v2 script, you would have seen this warning dialog:
If this - or a log warning - appears, and there is no user-defined Python in the workspace, it should be safe to simply change the Python Compatibility parameter of the workspace to 3.4+.
This article explains the situation in a bit more detail.
Are You Ready?So, we're ready, but are you?
I've not seen a definitive statement, but I strongly suspect that v2 soon won't ship at all with FME, starting with FME 2020. So if you have FME-specific v2 Python code, you'll want to look at it now as a matter of urgency.
You can find Python in a number of places in your workspace. It might be a startup script or it might be in a PythonCaller transformer. You'll want to make sure that all this code is valid for Python v3, and that you change the Compatibility parameter in FME; otherwise FME will still think it's v2 specific and complain to you!
Another place you can find Python code is in custom transformers, which is why I have another thought...
FME Hub SubmissionsDo you have any work on the FME Hub? Does it use Python, or is its compatibility set to Python 2?
If so, you may want to download and check/edit those components before FME 2020 releases. It's not just custom transformers, you may also have workspace templates uploaded too.
Already I've downloaded a couple of transformers and been hit with a pop-up error when I do. So for the sake of your users/fans, make sure you have everything ready for them.
FAQ- What about other packages I link to?
- What about other platforms than Windows?
All of these questions - and more - are answered in the article I mentioned above.
Yes, this one.
Seriously, that page is the source of all good information, so go check it out. And if you do still have questions, then let us know through the usual channels. But be quick about it (1 month, 2 days, 14 hours and 3 minutes...)
Answer of the WeekI don't normally have an answer of the week, but there was a great answer to a question I highlighted last week: how to find neighbors mathematically to improve performance.
Well done to @bwn for coming up with a solution, then implementing and testing it. It's the folk like you who do this for other users that make this community what it is. Thank you for contributing (and yes, I saw your comments, I just haven't had a chance to think about it yet. I will).
Other Notable QuestionsHere are some other notable questions this week:
- Is there a tab-separated option on the CSV writer?
- Why, yes @benvk, there is. The separator character doesn't always need to be a comma, despite what the format name implies. @bwasserstein explains how to achieve that..
- If I overlap two areas with numeric attributes, can I calculate the sum of those for the overlap?
- Yes, that is possible. @virtualcitymatt shows you how to sum those overlapping attributes.
- But perhaps @schorsch, you mean you want to calculate the proportion of those attribute values according to the area? That would be a little different. Let us know if that's what you want, because I think that too is possible. In general just calculate the area of each polygon before and after intersection, and apply those proportions to the summed attribute. This similar example may help.
- How do I prevent a transformer running until a writer has finished?
- @ramcgreg asked the question and @erik_jan noted that this would need a FeatureWriter transformer to do the writing, not an actual "writer".
- Of course, you still need to make sure that the features wait for the summary to exit the FeatureWriter. To do this requires a transformer that needs input from both streams. Then it is forced to wait. Having a bit of free time, I made a custom transformer to do that: the SequenceController.
OK, so this turned out to be not much of a shorter post than usual! But in brief, what I hope you take from this post is to check your Python scripts and ensure that they are all ready for v2 deprecation in.... 1 month, 2 days, 13 hours and 45 minutes!!!