Zero to Mastery: Python Monthly Newsletter 💻🐍

Planet Python - Tue, 2023-11-28 16:43
48th issue of Andrei Neagoie's must-read monthly Python Newsletter: Python 3.12 is Out, CLI Tools With Python, Career Advice, and much more. Read the full newsletter to get up-to-date with everything you need to know from last month.
Categories: FLOSS Project Planets

FSF News: Worldwide community of activists protest OverDrive and others forcing DRM upon libraries

GNU Planet! - Tue, 2023-11-28 16:22
BOSTON, Massachusetts, USA -- Tuesday, November 28, 2023 -- The Free Software Foundation (FSF) has announced its Defective by Design campaign's 17th annual International Day Against DRM (IDAD). It will protest uses of Digital Restrictions Management technology's hold over public libraries around the world, exemplified by corporations like OverDrive and Follett Destiny. IDAD will take place digitally and worldwide on December 8, 2023.
Categories: FLOSS Project Planets

Steinar H. Gunderson: Framework debt

Planet Debian - Tue, 2023-11-28 14:34

Today's shower thought:

Taking on a dependency is assuming some amount of technical debt. Using a framework is taking on a dependency that is very hard to get rid of.

(All the usual properties of technical debt, positive and negative, apply)

Categories: FLOSS Project Planets

PyCoder’s Weekly: Issue #605 (Nov. 28, 2023)

Planet Python - Tue, 2023-11-28 14:30

#605 – NOVEMBER 28, 2023
View in Browser »

Inline Dependencies for Small Python Scripts

Sabs wanted the ability to specify dependencies inside a single Python script, and although there are PEPs on this topic, their implementation is a ways off. Sabs decided to solve this problem directly: introducing pip.wtf a code snippet you copy into your script that does dependency loading through a function call.

Build Conway’s Game of Life With Python

In this step-by-step project, you’ll implement Conway’s Game of Life in Python. To make the game usable, you’ll create a user-friendly command-line interface (CLI) with several options that will allow you to run the game using different life patterns and configurations.

Master Python With Pybites PDM 🚀

Are you stuck in tutorial paralysis? Crush imposter syndrome with the 12-week Pybites PDM Program. Learn advanced Python, build impactful real world apps, and get 1:1 mentorship. Stand out in tech interviews and elevate your developer journey. Join a thriving Python community. Enroll today! 🐍👩‍💻
PYBITES sponsor

The Categories of Bugs in Python Apps

This article categorizes errors in your Python code into three groups: type-checking, import explosions, and runtime errors. Learn how each is treated differently and how to better handle them in your programs.

Django Ninja 1.0 Released


Python 3.13.0 Alpha 2 Is Now Available


Django 5.0 Release Candidate 1 Released


Discussions What’s the Coolest Thing You’ve Done With Python?


What’s It Like to Maintain an OSS Fork at Work?


Python Jobs Software Engineer - Intern (Summer 2024) (Dallas, TX, USA)

Causeway Capital Management

More Python Jobs >>>

Articles & Tutorials How to Render Markdown in a Django Application

In this tutorial, you’ll learn how to create and render web content in Django with the simplicity and flexibility of the Markdown text formatting language.

10 Truths They Won’t Tell You About a Software Job

This opinion piece from Mensur addresses the wide gulf between what is learned in school and what is encountered in real world software development. He mentions topics ranging from the frequency of dealing with legacy code, to the reality of meetings and estimates. Associated HN discussion.

A Disorganized List of Maintainer Tasks

David is the maintainer of Flask and this list shows all that entails. Some things are obvious and others are things you might not be aware of. If you’re participating in the OSS community, it is good to know what is on here, if you just use libraries, appreciate all the work being done!

One Liners Python Edition

A collection of single-line Python snippets that cover common tasks in programming. Includes removing duplicates from lists, reversing strings, finding the most common element in a list, and much more.

The Radiating Programmer

Love them or hate them, the daily stand-up is out there. It may have problems, but at its core, the three mains questions (what did you do? what are you planning? what is blocking you?) provide a tool for radiating information, and at core that’s a good idea.

Fixit 2: Meta’s Next-Generation Auto-Fixing Linter

Meta has a large collection of plug-ins for linting, which makes some of the usual solutions problematic at scale. This article introduces Fixit 2, an open source, pluggable linter.

Beginners Should Use Django, Not Flask

This opinion piece by Bite Code states why developers new to the web space should use Django, even though Flask has the simpler “hello world” which makes it attractive.

Error Culture

This multi-part post talks about how getting notified about all errors leads to error fatigue from false positives and a culture where errors get ignored. Long term this can have disastrous consequences.

Python Basics Exercises: Modules and Packages

In this video course, you’ll practice separating your code into modules, using the import statement to access another module’s namespace, and creating Python packages.

How to Write Efficient Python Code: A Tutorial for Beginners

Are you a programmer looking to get better at Python? Learn some of Python’s features that’ll help you write more elegant and Pythonic code.
BALA PRIYA C • Shared by Bala Priya C

The Changing “Guarantees” Given by Python’s GIL

This article covers the changes the Global Interpreter Lock has undergone since Python 3.9 and how that impacts the assumptions you can make in your code.

11 Fun Python Libraries to Make Your Day Better

This article covers 11 libraries that the author had fun playing with, including PyGame, Asciimatics, Arcade, and more.

datetime.utcnow() Is Now Deprecated

Python 3.12 has deprecated utcnow() and utcfromtimestamp(). This article covers why and what to use instead.

Projects & Code Simple Async Queue

SAQ-PY.READTHEDOCS.IO • Shared by Nickolas Grigoriadis

toga: A Python Native, OS Native GUI Toolkit


lato: Microframework for Modular Monoliths


hexabyte: A Modern, Modular, and Robust TUI Hex Editor


error-links: Add Links to Search Google to Your Tracebacks

GITHUB.COM/RODRIGOGIRAOSERRAO • Shared by Rodrigo Girão Serrão 🐍🚀

Events Weekly Real Python Office Hours Q&A (Virtual)

November 29, 2023

SPb Python Drinkup

November 30, 2023

PyLadiesCon 2023

December 2 to December 4, 2023

XtremePython 2023

December 5 to December 6, 2023

PyData Global 2023

December 6 to December 9, 2023

Pyjamas Conf 2023

December 9 to December 11, 2023

Sciwork 2023

December 9 to December 11, 2023

Happy Pythoning!
This was PyCoder’s Weekly Issue #605.
View in Browser »

[ Subscribe to 🐍 PyCoder’s Weekly 💌 – Get the best Python news, articles, and tutorials delivered to your inbox once a week >> Click here to learn more ]

Categories: FLOSS Project Planets

FSF Events: Free Software Directory meeting on IRC: Friday, December 01, starting at 12:00 EST (17:00 UTC)

GNU Planet! - Tue, 2023-11-28 14:10
Join the FSF and friends on Friday, December 01, from 12:00 to 15:00 EST (17:00 to 20:00 UTC) to help improve the Free Software Directory.
Categories: FLOSS Project Planets

Off-Theme Presents: Shades of Purple

Planet KDE - Tue, 2023-11-28 11:51
In the third installment of Off-Theme, we cover Shades of Purple, a global theme with a rather striking set of shades that sets it apart from many other flat themes.
Categories: FLOSS Project Planets

Tag1 Consulting: A Guide to Estimating Migrations - How Much Will My Drupal Migration Cost? Part 2/3

Planet Drupal - Tue, 2023-11-28 09:00

This podcast series focuses on the strategies involved in upgrading and migrating Drupal websites and applications.

Read more michaelemeyers Tue, 11/28/2023 - 06:00
Categories: FLOSS Project Planets

Real Python: Advent of Code: Solving Puzzles With Python

Planet Python - Tue, 2023-11-28 09:00

Advent of Code is an online Advent calendar where you’ll find new programming puzzles offered each day from December 1 to 25. While you can solve the puzzles at any time, the excitement when new puzzles unlock is really something special. You can participate in Advent of Code in any programming language—including Python!

With the help of this Code Conversation, you’ll be ready to start solving puzzles and earning your first gold stars.

In this video course, you’ll learn:

  • What an online Advent calendar is
  • How solving puzzles can advance your programming skills
  • How you can participate in Advent of Code

Advent of Code puzzles are designed to be approachable by anyone with an interest in problem-solving. You don’t need a heavy computer science background to participate. Instead, Advent of Code is a great arena for learning new skills and testing out new features of Python.

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

Open Source AI: Establishing a common ground

Open Source Initiative - Tue, 2023-11-28 08:00

The current draft v. 0.0.3 of the Open Source AI Definition borrows wordings from the GNU Manifesto’s golden rule stating: 

If I like a program, I must be able to share it with others who like it.

The GNU Manifesto

The GNU Manifesto refers to “program” (not “AI system”), without the need to define it.  When it was published in 1985, the definition of a program was pretty clear. Today’s scene around artificial intelligence is not as clear and there are multiple definitions for AI systems floating around.

The process of finding a shared definition of Open Source AI is only in its infancy. I’m fully aware that for many of us here this is trivial and this phase is almost boring. 

But the four workshops revealed that a significant number of people in the rooms did not know the 4 Freedoms nor had any idea that OSI has a formal Open Source Definition. And this happened also at two Open Source-focused events!

Which definition of AI system to adopt

I don’t think the Open Source community should write its own definition of an AI system as there are too many dangers with doing that. Most importantly, adopting a vocabulary foreign to the AI world increases the risks of not being understood or accepted. It’s a lot more effective and will be more palatable to use a widely adopted definition.

The OECD definition of AI system

The Organisation for Economic Co-operation and Development (OECD) published one in 2019 and updated it in November 2023. OECD’s definition has been adopted by the United Nations, NIST and the AI Act may use it too. 

An AI system is a machine-based system that, for explicit or implicit objectives, infers, from the input it receives, how to generate outputs such as predictions, content, recommendations, or decisions that can influence physical or virtual environments. Different AI systems vary in their levels of autonomy and adaptiveness after deployment

Recommendation of the Council on Artificial Intelligence Adopted on:  22/05/2019; Amended on:  08/11/2023

 I discovered a 2022 document of the OECD with a slightly amended definition from the one of 2019.The 2022 OECD Framework for the Classification of AI systems removes the words “or decisions” from their previous definition, saying in the note :

Experts Working Group decided [“or decisions”] should be excluded here to clarify that an AI system does not make an actual decision, which is the remit of human creators and outside the scope of the AI system 

2022 OECD Framework for the Classification of AI systems

The updated definition used by the Experts WG is:

An AI system is a machine-based system that is capable of influencing the environment by producing recommendations, predictions or other outcomes for a given set of objectives. It uses machine and/or human-based inputs/data to:

  1. perceive environments;
  2. abstract these perceptions into models; and
  3. use the models to formulate options for outcomes.

AI systems are designed to operate with varying levels of autonomy (OECD, 2019f[2]).”

2022 OECD Framework for the Classification of AI systems

Surprisingly, the version amended in November 2023 by the OECD still uses the words “or decisions”.

The definition of AI system for US National Institute of Standards (NIST)

NIST AI Risk Management Framework slightly modified the OECD definition that includes the word “outputs”:

The AI RMF refers to an AI system as an engineered or machine-based system that can, for a given set of objectives, generate outputs such as predictions, recommendations, or decisions influencing real or virtual environments. AI systems are designed to operate with varying levels of autonomy (Adapted from: OECD Recommendation on AI:2019; ISO/IEC 22989:2022)

AI Risk Management Framework The definition of AI system in Europe

To complete the picture, I also looked at the EU. In a document from 2019, in the early days of the legislative process, the expert group on AI suggested: https://digital-strategy.ec.europa.eu/en/policies/european-approach-artificial-intelligence:

Artificial intelligence (AI) systems are software (and possibly also hardware) systems designed by humans that, given a complex goal, act in the physical or digital dimension by perceiving their environment through data acquisition, interpreting the collected structured or unstructured data, reasoning on the knowledge, or processing the information, derived from this data and deciding the best action(s) to take to achieve the given goal. AI systems can either use symbolic rules or learn a numeric model, and they can also adapt their behaviour by analysing how the environment is affected by their previous actions.

As a scientific discipline, AI includes several approaches and techniques, such as machine learning (of which deep learning and reinforcement learning are specific examples), machine reasoning (which includes planning, scheduling, knowledge representation and reasoning, search, and optimization), and robotics (which includes control, perception, sensors and actuators, as well as the integration of all other techniques into cyber-physical systems).

High-Level expert group on AI: Ethics guidelines for trustworthy AI

It’s worth noting that this definition is not used in the AI Act. The text of the EU Council suggests this one be used: 

artificial intelligence system’ (AI system) means a system that

  1. receives machine and/or human-based data and inputs,
  2. infers how to achieve a given set of human-defined objectives using learning, reasoning or modelling implemented with the techniques and approaches listed in Annex I, and
  3. generates outputs in the form of content (generative AI systems), predictions, recommendations or decisions, which influence the environments it interacts with;

which seems to be quite similar to the OECD text.

Why we need to adopt a definition of AI system

There is agreement that the Open Source AI Definition needs to cover all AI implementations and not be specific to machine learning, deep learning, computer vision or other branches. That requires using a generic term. For software, the word “program” covers everything, from assembly, interpreted to compiled languages. “AI system” is the equivalent in the context of artificial intelligence.

“Program” is to software as “AI system” is to artificial intelligence.

In the document What is Free Software, the GNU project describes four fundamental freedoms that the “program” must carry to its users. Draft v. 0.0.3 similarly describes four freedoms that the AI system needs to deliver to its users.

In v. 0.0.3 draft there was debate on the wording of the freedom — freedom to modify. For software, that’s the freedom to modify the program to better serve user’s needs, fix bugs, etc. Draft v. 0.0.3 says:

Modify the system to change its recommendations, predictions or decisions to adapt to your needs.

Draft v.0.0.3

The intention to specify what the object of the change is to establish the principle that anyone should have the right to modify the behavior of the AI system as a whole. The words “recommendations, predictions or decisions” come from the definition of AI system: what does the “system” do and what would I want to modify?

That’s why it’s important to say what it is we expect to have the right to modify. Tying that to an agreed-upon definition of what an AI system does is a way to make sure that all readers are on the same page.

We can change the wordings for that bullet point but I think the verb “modify” should refer to the whole system, not individual components.

We’re trying to adopt a definition of an AI system that is widely understood and accepted, even though it’s not strictly correct scientifically. The Open Source AI Definition should align with other policy documents because many communities (legal, policy makers and even academia) will have to align too. 

The newest definition of AI system from the OECD is the best candidate, without the words “or decisions.”

Next steps

I met with the Digital Public Goods Alliance in Addis Ababa on November 14. I expected to encounter a different assortment of competences than the ones I’ve met so far, and that was true. How far we are from consensus on basic principles is something I’m contemplating before releasing draft v.0.0.4 and move on to the next phase of public conversations. For 2024 we’re planning a regular cadence of meetings (online and in- person) and a release roadmap leading to a v. 1.0 before the end of the year. More to come.

The post <span class='p-name'>Open Source AI: Establishing a common ground</span> appeared first on Voices of Open Source.

Categories: FLOSS Research

ListenData: How to Get Unique Values in a Column in Pandas DataFrame

Planet Python - Tue, 2023-11-28 07:17

This tutorial explains how to get unique values from a column in Pandas DataFrame, along with examples.

Find Unique Values in a Column df['columnName'].unique() To read this article in full, please click hereThis post appeared first on ListenData
Categories: FLOSS Project Planets

Enrico Zini: Introducing Debusine

Planet Debian - Tue, 2023-11-28 05:12

Debusine manages scheduling and distribution of Debian-related tasks (package build, lintian analysis, autopkgtest runs, etc.) to distributed worker machines. It is being developed by Freexian with the intention of giving people access to a range of pre-configured tools and workflows running on remote hardware.

Freexian obtained STF funding for a substantial set of Debusine milestones, so development is happening on a clear schedule. We can present where we are and, we're going to be, and what we hope to bring to Debian with this work.

Categories: FLOSS Project Planets

Python Bytes: #362 You can deprecate a global variable?

Planet Python - Tue, 2023-11-28 03:00
<strong>Topics covered in this episode:</strong><br> <ul> <li><a href="https://vadimkravcenko.com/shorts/habits-of-great-software-engineers"><strong>Habits of great software engineers</strong></a></li> <li><a href="https://flask.palletsprojects.com/en/3.0.x/changes/"><strong>Flask 3.0</strong></a></li> <li><a href="https://realpython.com/conway-game-of-life-python"><strong>Build Conway's Game of Life With Python</strong></a></li> <li><a href="https://github.com/MarcoGorelli/polars-business"><strong>polars business</strong></a></li> <li><strong>Extras</strong></li> <li><strong>Joke</strong></li> </ul><a href='https://www.youtube.com/watch?v=G2sLEhjIRHA' style='font-weight: bold;'>Watch on YouTube</a><br> <p><strong>About the show</strong></p> <p>Sponsored by <a href="https://pythonbytes.fm/scout"><strong>Scout APM</strong></a></p> <p><strong>Connect with the hosts</strong></p> <ul> <li>Michael: <a href="https://fosstodon.org/@mkennedy"><strong>@mkennedy@fosstodon.org</strong></a></li> <li>Brian: <a href="https://fosstodon.org/@brianokken"><strong>@brianokken@fosstodon.org</strong></a></li> <li>Show: <a href="https://fosstodon.org/@pythonbytes"><strong>@pythonbytes@fosstodon.org</strong></a></li> </ul> <p>Join us on YouTube at <a href="https://pythonbytes.fm/stream/live"><strong>pythonbytes.fm/live</strong></a> to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.</p> <p><strong>Brian #1:</strong> <a href="https://vadimkravcenko.com/shorts/habits-of-great-software-engineers"><strong>Habits of great software engineers</strong></a></p> <ul> <li>As we wind up the year, many people are thinking about goals for the new year.</li> <li>Here’s a decent list to think about <ul> <li>Focusing beyond the code </li> <li>Efficiency / Antifragility</li> <li>Joy of tinkering </li> <li>Knowing the why </li> <li>Thinking in systems </li> <li>Tech detox </li> <li>The art of approximation</li> <li>Transferring Knowledge to Other Problems</li> <li>Making Hard Things Easy</li> <li>Playing the Long Game</li> <li>Developing a Code Nose</li> <li>Strong Opinions loosely held</li> </ul></li> </ul> <p><strong>Michael #2:</strong> <a href="https://flask.palletsprojects.com/en/3.0.x/changes/"><strong>Flask 3.0</strong></a></p> <ul> <li>Deprecate the <code>__version__</code> attribute. Use feature detection, or <code>importlib.metadata.version("flask")</code>, instead. #5230 <ul> <li>How do you <a href="https://github.com/pallets/flask/pull/5242/files">even do that</a>?</li> </ul></li> <li><p>This is news to me:</p> <pre><code>[build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" [metadata] name = "your-package-name" version = "0.1.0" </code></pre></li> <li><p>Remove previously deprecated code. <a href="https://github.com/pallets/flask/pull/5223">#5223</a></p></li> </ul> <p><strong>Brian #3:</strong> <a href="https://realpython.com/conway-game-of-life-python"><strong>Build Conway's Game of Life With Python</strong></a></p> <ul> <li>Leodanis Pozo Ramos</li> <li>CLI curses version</li> <li>Nice walk through of breaking the problem into parts.</li> </ul> <p><strong>Michael #4:</strong> <a href="https://github.com/MarcoGorelli/polars-business"><strong>polars business</strong></a></p> <ul> <li>It's a plugin for Polars, which allows you to do business day arithmetic.</li> <li>The big advantage of using this directly (as opposed to converting to pandas/numpy, using their business day tools, and then converting back) is that polars-business fits right in with the Polars lazy API. This means you'll still be able to get the gains from the Polars query optimiser without having to step into eager execution.</li> <li>All you need to use is it is <code>pip install polars-business</code></li> <li>Written in Rust, but end-users doesn't need Rust to run it, Python is all you need.</li> </ul> <p><strong>Extras</strong> </p> <p>Brian:</p> <ul> <li>BLACKFRIDAY code still works for 50% off <a href="https://courses.pythontest.com/p/complete-pytest-course">The Complete pytest Course,</a> Full Course + Community Access, through Nov 30</li> <li>Also Debugging chapter is up, and it includes a small TDD example.</li> </ul> <p>Michael:</p> <ul> <li><a href="https://twitter.com/kennethreitz42/status/1726816318303752511">Dear Python Community</a> by Kenneth Reitz</li> <li><a href="https://discuss.python.org/t/python-3-13-0-alpha-2/39379">Python 3.13a2 out and Major new features of the 3.13 series, compared to 3.12</a></li> <li>Thank you Black Friday supporters. </li> </ul> <p><strong>Joke:</strong> </p> <ul> <li><a href="https://www.reddit.com/r/programminghumor/comments/171i41r/select/">ai vs dev</a></li> </ul>
Categories: FLOSS Project Planets

Specbee: Handling Custom Drupal Migrations Using SqlBase

Planet Drupal - Tue, 2023-11-28 02:20
There’s so much going on in the world of Drupal migrations. Drupal 9 reached its End Of Life (EOL) on November 1, 2023. Drupal 7 will reach EOL by January 2025 (final extension). Drupal 10 was released back in December 2022 and its current version, 10.1.6 was released on November 1, 2023. More than twelve thousand sites have already migrated to the current version of Drupal 10 (according to the Upgrade Status module download stats). In this article, we’ll take you through the different Drupal migration methods and especially focus on custom migrations using the SqlBase source plugin. Take a look! In Technical Terms, What is a Drupal Migration? Drupal migration is the process of moving content, data, and configuration from another CMS (or an older version of Drupal) to Drupal. A migration consists of several steps: Extract, Transform, and Load (ETL). In the Drupal world, we refer to these as source plugins, process plugins, and destination plugins. The Extract phase is known as the source, Transform is the process, and Load is the destination. Drupal Migration Methods When migrating your website from Drupal 7 to Drupal 9 or a later version, there are primarily two migration methods available. Migration UI  Drush (Custom migration) Migration UI  When you want to migrate your entire web application, including all configurations and content, to a later version, you can use Migration UI. It's a straightforward option that doesn't require in-depth knowledge of Drupal APIs. This approach can be used where your site is not too complex in terms of site architecture and considering all the modules used in Drupal 7 are also available in the target version (Drupal 9 or Drupal 10). Custom Migration When you are rewriting your website with a more modern and performance-centric approach which leads to significant changes in the architecture of your new website from Drupal 9, Migration UI literally won’t work. In such cases, you’ll need to roll up your sleeves and build custom migration scripts. Migration Process Let’s dig deeper into the migration process. It comprises of 3 major processes. Source plugin (Extract) Process plugin (Transform) Destination plugin (Load) Source Plugin Source plugins handle the extraction of data from various sources, which can be in different formats, including raw data, databases, and CSV/XML/JSON files. They extract data from these sources and pass it on to the next phase in the migration process. Process Plugin The process plugin works on the source data, restructuring it to match the destination process. It transforms the data into an array, where each key corresponds to a destination property. The values assigned to each key determine how the destination values for your new website are generated. More details can be found here. Destination plugin The destination plugin processes the structured data and saves it on your website. The most common destination plugins are node, term, user, and media. You likely have a grasp of the migration process. Now, let's delve deeper into source plugins, with a specific focus on the SqlBase source plugin. Thinking of migrating your Drupal 7 website to Drupal 10? Get your Drupal 7 Site Audit report for Free! Using SqlBase for the Drupal Migration What is SqlBase migration? SqlBase migration is straightforward—it allows you the flexibility to create your custom SQL queries to obtain the desired output. Other than that, it follows the same principles as other Drupal migration methods. Why should you use SqlBase Migration? When your site has a straightforward field structure, content types, etc., Drupal core migration can handle it. However, challenges arise with obsolete field types in Drupal 9 or when restructuring an old website with various content types. If you aim for an editor-friendly and performance-oriented site, a simple migration won't suffice. You'll need to prepare your source data and take the SqlBase migration route. In another scenario, if your current site, built on a platform other than Drupal, provides data in the form of a database, SqlBase migration is also the way to go. Benefits of leveraging SqlBase Migration Since this is SqlBase, the speed of your migration relies entirely on how well you craft your database queries. The better your query preparation, the faster the migration will run. It doesn't rely on many core migration processes; you have the flexibility to shape and process your data as you see fit. The SqlBase Source Plugin must implement these three methods: query(): Returns the SQL query that selects the data from the source database. fields(): Returns available fields on the source. getIds(): Defines the source fields uniquely identifying a source row Let’s get into the details of what these functions should contain: query() function /** * {@inheritdoc} */ public function query() { $query = $this->select('job_details', 'c') ->fields('c', array( 'id', 'title', 'description',o 'position', 'company', 'criteria', )); return $query; }fields() function /** * {@inheritdoc} */ public function fields() { $fields = array( 'id'= $this->t('Autoincrement ID'), 'title' = $this->t('Job Title'), 'description' = $this->t('Job Description'), 'position' = $this->t('Job Position'), 'company'.= $this->t('Company'), 'criteria' = $this-»t('Job Criteria'), ); return $fields; }getIds() function /** * {@inheritdoc} */ public function getIds() { return [ 'id' => [ 'type' => 'integer', 'alias'=>'j' ]; }Additionally, you can tweak your SQL result by using the prepareRow() function and even add new source properties to your migration. /** * {@inheritdoc} */ public function prepareRow(Row $row) { $company = $row->getSourceProperty('company'); $row->setSourceProperty('job_type', 'on-site'); if ($company == 'specbee') { $row->setSourceProperty('job_type', 'remote'); } return parent::prepareRow($row); }These source properties will be sent to your migration yml files and you can also use your own processor if you want any additional processing on your source data. Referenceshttps://www.drupal.org/project/usage/3398311 Final Thoughts With Drupal 9's EOL, the impending farewell to Drupal 7, and the rise of Drupal 10, the need for seamless transitions has never been more pressing. As Drupal evolves, our Drupal Development Company recognizes SqlBase as an essential tool for a seamless and efficient migration process. Offering the flexibility to shape personalized SQL queries, it plays a vital role in crafting tailored data transitions. If you’re looking for a reliable Drupal migration partner, we’re just a form away! 
Categories: FLOSS Project Planets

Greg Casamento: Objective-C end of life?? Not a chance...

GNU Planet! - Mon, 2023-11-27 23:41
Recently, I saw this article regarding ObjCs "end of life" from JetBrains.

The tiobe index seems to disagree. It’s also important to remember that jetbrains recently had to take down their AppCode application (which sucked) since it didn’t sell.
Jetbrains is the creator of the kotlin language so they have a vested interest in their android customers. I would take their “index” with a grain of salt to say the least.

While it is certain that Apple won’t be investing into thing beyond ObjC 2.0, it is foolhardy to think that ObjC is going away anytime soon since there is an enormous installed base of stable code, not the least of which is Foundation and AppKit themselves. Also consider CocoaPods.

So, no, not worried about it. Also… look at Java and COBOL. For years people have declared the end of both languages. Java is still popular, though not in vogue and COBOL while not one of the “cool kids” has literally billions of lines of code being maintained and new code being written every year. This (admittedly biased as it is by the CTO of MicroFocus) article gives some reasons why….

Here is the article about COBOL...

Plus… Apple already has a mechanism for automatically allowing objc and swift to work together. Take a look at the frameworks in Xcode and you’ll notice some files called *.apinotes. These are YAML files that are used by the compiler to allow easy integration into swift projects. So, essentially, if Apple writes an ObjC version of a framework they get the swift version for absolutely free (minus the cost of writing the YAML file). If they write a swift only version they don’t get that benefit.

So, yeah, in conclusion… Yes, ObjC is NOT on the rise, but reports of its demise have been greatly exaggerated! ;)

PS. That being said, Apple dumping ObjC might spell a boom for us as all of the people who have installed codebases would suddenly need support for it either on macOS (on which we don’t currently work) or on other platforms. Something to think about…

PPS. All of the above being said. I admit I wouldn’t be terribly shocked to hear from Apple that “we have dropped support for the legacy objc language to provide you with the best support for our new swift language to make it the ‘greatest developer experience in the world’” or some grotesque BS like that. Lol

Categories: FLOSS Project Planets

Dirk Eddelbuettel: RcppCNPy 0.2.12 on CRAN: More Maintenance

Planet Debian - Mon, 2023-11-27 19:36

A new (and again somewhat minor) maintenance release of the RcppCNPy package arrived on CRAN earlier today.

RcppCNPy provides R with read and write access to NumPy files thanks to the cnpy library by Carl Rogers along with Rcpp for the glue to R.

Recent changes in r-devel hone in on issues concerning printf format string inaccuracies the compiler can detect via the -Wformat -Wformat-security flags. Two fairly simplye ones were present here and have been addressed. In the time since the last release about twenty months ago two or three other minor packaging and setup details have also been taken care of, details are below.

Changes in version 0.2.12 (2022-11-27)
  • The continuous integration workflow received a trivial update, twice.

  • The C++ compilation standard is now implicit per CRAN and R preference.

  • The CITATION file format has been updated for the current usage.

  • Two print format string issues reported by current R-devel have been addressed.

CRANberries also provides a diffstat report for the latest release. As always, feedback is welcome and the best place to start a discussion may be the GitHub issue tickets page.

If you like this or other open-source work I do, you can now sponsor me at GitHub.

This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.

Categories: FLOSS Project Planets

François Marier: Automatically rebooting for kernel updates

Planet Debian - Mon, 2023-11-27 18:30

I use reboot-notifier on most of my servers to let me know when I need to reboot them for kernel updates since I want to decide exactly when those machines go down. On the other hand, my home backup server has very predictable usage patterns and so I decided to go one step further there and automate these necessary reboots.

To do that, I first installed reboot-notifier which puts the following script in /etc/kernel/postinst.d/reboot-notifier to detect when a new kernel was installed:

#!/bin/sh if [ "$0" = "/etc/kernel/postinst.d/reboot-notifier" ]; then DPKG_MAINTSCRIPT_PACKAGE=linux-base fi echo "*** System restart required ***" > /var/run/reboot-required echo "$DPKG_MAINTSCRIPT_PACKAGE" >> /var/run/reboot-required.pkgs

Note that unattended-upgrades puts a similar script in /etc/kernel/postinst.d/unattended-upgrades:

#!/bin/sh case "$DPKG_MAINTSCRIPT_PACKAGE::$DPKG_MAINTSCRIPT_NAME" in linux-image-extra*::postrm) exit 0;; esac if [ -d /var/run ]; then touch /var/run/reboot-required if ! grep -q "^$DPKG_MAINTSCRIPT_PACKAGE$" /var/run/reboot-required.pkgs 2> /dev/null ; then echo "$DPKG_MAINTSCRIPT_PACKAGE" >> /var/run/reboot-required.pkgs fi fi

and so you only need one of them to be installed since they both write to /var/run/reboot-required. It doesn't hurt to have both of them though.

Then I created the following cron job (/etc/cron.daily/reboot-local) to actually reboot the server:

#!/bin/bash REBOOT_REQUIRED=/var/run/reboot-required if [ -s $REBOOT_REQUIRED ] ; then cat "$REBOOT_REQUIRED" | /usr/bin/mail -s "Rebooting $HOSTNAME" root /bin/systemctl reboot fi

With that in place, my server will send me an email and then automatically reboot itself.

This is a work in progress because I'd like to add some checks later on to make sure that no backup is in progress during that time (maybe by looking for active ssh connections?), but it works well enough for now. Feel free to leave a comment if you've got a smarter script you'd like to share.

Categories: FLOSS Project Planets

PreviousNext: Drupal front-end nirvana with Vite, Twig and Storybook

Planet Drupal - Mon, 2023-11-27 16:14

We're proud to announce the release of vite-plugin-twig-drupal, a plugin for Vite that we hope will improve your workflow for front-end development with Drupal.

by lee.rowlands / 28 November 2023The problem space

You're working with Twig in a styleguide-driven-development process. You're writing isolated components that consist of CSS, Twig and JavaScript. You want to be able to use Twig to render your components for Storybook. You want fast refresh with Vite. You want Twig embeds, includes and extends to work. You want to use Drupal-specific twig features like create_attributes etc. You want compilation of PostCSS and SASS to CSS. You want Hot Module Reloading (HMR) so that you can see how your components look without needing to endlessly refresh.

Enter vite-plugin-twig-drupal

The Vite plugin Twig Drupal is a Vite plugin based on Twig JS for compiling Twig-based components into a JavaScript function so that they can be used as components with Storybook. It allows you to import Twig files into your story as though they are JavaScript files.

Comparison to other solutions
  • Vite plugin twig loader doesn't handle nested includes/embeds/extends. These are a fairly crucial feature of Twig when building a component library as they allow re-use and DRY principles
  • Components library server requires you to have a running Drupal site. Whilst this ensures your Twig output is identical to that of Drupal (because Drupal is doing the rendering), it is a bit more involved to setup. If you're going to use single directory components or a similar Drupal module like UI patterns then this may be a better option for you.

This module is distributed via npm, which is bundled with node and should be installed as one of your project's devDependencies:

npm install --save-dev vite-plugin-twig-drupal

You then need to configure your vite.config.js.

import { defineConfig } from "vite" import twig from 'vite-plugin-twig-drupal'; import { join } from "node:path" export default defineConfig({ plugins: [ // Other vite plugins. twig({ namespaces: { components: join(__dirname, "/path/to/your/components"), // Other namespaces as required. }, // Optional if you are using React storybook renderer. The default is 'html' and works with storybook's html // renderer. // framework: 'react' }), // Other vite plugins. ], })

With this config in place, you should be able to import Twig files into your story files.


To make use of a Twig file as a Storybook component, just import it. The result is a component you can pass to Storybook or use as a function for more complex stories.

// stories/Button.stories.js // Button will be a Javascript function that accepts variables for the twig template. import Button from './button.twig'; // Import stylesheets, this could be a sass or postcss file too. import './path/to/button.css'; // You may also have JavaScript for the component. import './path/to/some/javascript/button.js'; export default { title: 'Components/Button', tags: ['autodocs'], argTypes: { title: { control: { type: 'text' }, }, modifier: { control: { type: 'select' }, options: ['primary', 'secondary', 'tertiary'], }, }, // Just pass along the imported variable. component: Button, }; // Set default variables in the story. export const Default = { args: { title: 'Click me' }, }; export const Primary = { args: { title: 'Click me', modifier: 'primary' }, }; // Advanced example. export const ButtonStrip = { name: 'Button group', render: () => ` ${Button({title: 'Button 1', modifier: 'primary'})} ${Button({title: 'Button 2', modifier: 'secondary'})} ` }

Here's how that might look in Storybook (example from the Admin UI Initiative storybook)

Dealing with Drupal.behaviors

In cases where the JavaScript you import into your story file uses a Drupal behavior, you'll likely need some additional code in your Storybook configuration to handle firing the behaviors. Here at PreviousNext, we prefer to use a loadOnReady wrapper, which works with and without Drupal. However, if you're just using Drupal.behaviors something like this in your Storybook config in main.js (or main.ts) will handle firing the behaviors.

const config = { // ... existing config previewBody: (body) => ` window.Drupal = window.Drupal || {behaviors: {}}; window.drupalSettings = Object.assign(window.drupalSettings || {}, { // Mock any drupalSettings your behaviors need here. }); // Mock Drupal's once library too. window.once = (_, selector) => document.querySelectorAll(selector); document.addEventListener('DOMContentLoaded', () => { Object.entries(window.Drupal.behaviors).forEach(([key, object]) => object.attach(document)); }) ${body} ` // ... more config }Give it a try

We're looking forward to using this plugin in client projects and are excited about the other possibilities Storybook provides us with, such as interaction and accessibility testing.

Thanks to early testers in the community, such as Ivan Berdinsky and Sean Blommaert, who've already submitted some issues to the github queue. We're really happy to see it in use in the Admin Initiative's work on a new toolbar.

Give it a try, and let us know what you think.

Tagged Storybook, Front End Development
Categories: FLOSS Project Planets

The Drop Times: Droopler's Next Chapter: Grzegorz Pietrzak's Insights | Part 2

Planet Drupal - Mon, 2023-11-27 14:59
In this insightful interview segment, Grzegorz Pietrzak, the tech lead of Droopler, sheds light on how Droopler stands out in corporate website building. With a focus on the growing demand from enterprises, Pietrzak accentuates the distinctive features and integrations that position Droopler as the preferred choice. Exploring the nuanced balance between swift development and upholding Drupal's fundamental freedoms, he provides a sneak peek into Droopler's continuous evolution and hints at significant upcoming changes. For a more understanding, dive into the complete interview.
Categories: FLOSS Project Planets

The Drop Times: Drupal Core 10.3.0 Upgrade Enables Seamless Integration of Computed Bundle Fields in Views

Planet Drupal - Mon, 2023-11-27 14:59
The recent Drupal Core version 10.3.0 update brings a notable improvement for module developers, allowing the effortless integration of computed fields designated as bundle fields within Views. This enhancement streamlines the process of declaring and utilizing computed bundle fields, providing a more flexible approach to managing dynamic data in Drupal-based web development.
Categories: FLOSS Project Planets