Search

Clear filter
Announcement
Larry Finlayson · May 4, 2022

InterSystems Virtual Classroom Training and Certification Exam News

Learning Services has posted the calendar for virtual classroom training through September! All classes are held 9am to 5pm US Eastern time as live, instructor-led virtual classrooms with hands-on exercises and interactive discussions. Go to classroom.intersystems.com to view the schedule, register for a class, or request a private training for 5-15 people at your company. Taking our classes are part of a great way to prepare for our professional certification exams! Of note, September 7-9 we are offering the InterSystems Change Control: Tier 1 Basics training which is part of the recommended preparation for the new InterSystems CCR Technical Implementation Specialist exam. Go to certification.intersystems.com to read about the available exams, requirements, and scheduling instructions. Also, InterSystems Certification will be proctoring free certification exams ($150 value) at Global Summit 2022. This is a great opportunity for people to prep for Professional Certification as a CCR Technical Implementation Specialist!!
Article
Evgeny Shvarov · May 4, 2022

The Update for a Default Dockerfile Template for development with InterSystems IRIS

Hi developer folks! Thanks to all of you who start the development with InterSystems IRIS from the basic development template! Recently, thanks to @Dmitry.Maslennikov's contributions I've updated the Dockerfile to make the development simpler, images lighter and the building process faster. And it looks more beautiful too ;) Here is what changed: Let's go through the changes: 1. Lines 11-15 were substituted to only one line 7, that sets the WORKDIR. WORKDIR /home/irisowner/irisbuild Indeed, if the WORKDIR points to a home folder of the user that runs iris then there is no need to perform security adjustments. Of course I should change the line in iris.script to load zpm module from another workdir folder 2. Lines 17-21 were COPY commands that I used to use to copy different files from source folder of repo to an image to use it for iris or the environment. now all these were substituted with one line RUN --mount=type=bind,src=.,dst=. \ This syntax uses buildkit feature of Docker that allows mount files you need in the image without actually coping it. This saves the space and speeds up the building process. So with this you can forget about COPY commands at all: everything from the repo folder will be mounted and available in a WORKDIR during the build phase. Beautiful, isn't it? Make sure you have this option turned on in your Docker: 3. What's added is the line with TEST parameter: ARG TESTS=0 If TESTS=1 it makes Dockerfile to call unittest for ZPM module you develop in the project. This is being controlled with the following line: ([ $TESTS -eq 0 ] || iris session iris "##class(%ZPM.PackageManager).Shell(\"test $MODULE -v -only\",1,1)") && \ This TESTS parameter also helps to perform unit test automatically during the CI. This deserves and additional topic to discuss and I'll continue with this in the next article. Or you can check it in Dmitry's code if you don't want to wait ) Hope you liked it, but friendly feedback, concerns and pull requests are very welcome! Happy coding! Great initiative, I will try to apply this to most of my repository. BTW, there is an easy way to enable BuildKit without editing the config file of docker : Unix : ```sh DOCKER_BUILDKIT=1 docker-compose build ``` Windows : ```sh set "DOCKER_BUILDKIT=1" & docker-compose build ``` To find this quoting in Windows kept me busy for quite a while 2 months agoas it wasn't part of the README.md ! GRAND MERCI ! Thanks, @Guillaume.Rongier7183! Nice finding on the BUILDKIT! Direct source code mounting in image is must have, thank you!
Announcement
Evgeny Shvarov · May 7, 2022

InterSystems Grand Prix Contest 2022 Technical Bonuses

Hi developers! InterSystems Grand Prix unites all the key features of InterSystems data platforms! Thus we invite you to use the following features and collect additional technical bonuses that will help you to win the prize! Here we go! InterSystems FHIR - 5 IntegratedML - 4 Native API - 3 Interoperability - 3 Production EXtension(PEX) - 4 Embedded Python - 5 Adaptive Analytics (AtScale) Cubes usage - 4 Tableau, PowerBI, Logi usage - 3 InterSystems IRIS BI - 3 Docker container usage - 2 ZPM Package deployment - 2 Online Demo - 2 Unit Testing - 2 First Article on Developer Community - 2 Second Article On DC - 1 Code Quality pass - 1 Video on YouTube - 3 InterSystems FHIR as a Service and IRIS For Health - 5 points We invite all developers to build new or test existing applications using InterSystems FHIR Server (FHIRaaS). Sign in to the portal, make the deployment and start using your InterSystems FHIR server on AWS in your application for the programming contest. You can also build an FHIR application using InterSystems IRIS for Health, docker version. You can take the IRIS-FHIR-Template which prepares the FHIR server during the docker image building. The documentation for FHIR API 4.0.1 could be found here. Learn more in InterSystems IRIS for Health documentation. IntegratedML usage - 4 points 1. Use InterSystems IntegratedML in your AI/ML solution. Here is the template that uses it. InterSystems IntegratedML template 2. Data import tools: Data Import Wizard CSVGEN - CSV import util CSVGEN-UI - the web UI for CSVGEN 3. Documentation: Using IntegratedML 4. Online courses & videos: Learn IntegratedML in InterSystems IRIS Preparing Your Data for Machine Learning Predictive Modeling with the Machine Learning Toolkit IntegratedML Resource Guide Getting Started with IntegratedML Machine Learning with IntegratedML & Data Robot InterSystems Native API usage - 3 points You get this bonus if you access the data in your Full-Stack application using any of the InterSystems Native API options: .NET, Java, Python, Node.js. Learn more here. Interoperability Productions with BPL or DTL - 3 points One of the key features of IRIS Interoperability Productions is a business process, which could be described by BPL (Business Process Language). Learn more about Business Processes in the documentation. Business Rule is a no-code/low-code approach to managing the processing logic of the interoperability production. In InterSystems IRIS you can create a business rule which you can create visually or via the ObjectScript representation. You can collect the Business Process/Business Rule bonus if you create and use the business process or business rule in your interoperability production. Business Rule Example Learn more on Business Rules in the documentation Production EXtension (PEX) Usage - 4 points PEX is a Python, Java or .NET extension of Interoperability productions. You get this bonus if you use PEX with Python, JAVA or .NET in your interoperability production. PEX Demo. Learn more on PEX in Documentation. InterSystems IRIS has Python Pex module that provides the option to develop InterSystems Interoperability productions from Python. Use it and collect 3 extra points for your application. It's OK also to use alternative python.pex wheel introduced by Guillaume Ronguier. Embedded Python - 4 points Use Embedded Python in your application and collect 4 extra points. You'll need at least InterSystems IRIS 2021.2 for it. Adaptive Analytics (AtScale) Cubes usage - 4 pointsInterSystems Adaptive Analytics provides the option to create and use AtScale cubes for analytics solutions. You can use the AtScale server we set up for the contest (URL and credentials can be collected in the Discord Channel) to use cubes or create a new one and connect to your IRIS server via JDBC. The visualization layer for your Analytics solution with AtScale can be crafted with Tableau, PowerBI, Excel, or Logi. Documentation, AtScale documentation Training Tableau, PowerBI, Logi usage - 3 points Collect 3 points for the visualization you made with Tableau, PowerBI, or Logi - 3 points per each. Visualization can be made vs a direct IRIS BI server or via the connection with AtScale. Logi is available on behalf of the InterSystems Reports solution - you can download the composer on InterSystems WRC. A temporary license can be collected in the discord channel. Documentation Training InterSystems IRIS BI - 3 points InterSystems IRIS Business Intelligence is a feature of IRIS which gives you the option to create BI cubes and pivots against persistent data in IRIS and deliver then this information to users using interactive dashboards. Learn more The basic iris-analytics-template contains examples of an IRIS BI cube, pivot, and a dashboard. Here is the set of examples of IRIS BI solutions: Samples BI Covid19 analytics Analyze This Game of Throne Analytics Pivot Subscriptions Error Globals Analytics Creating InterSystems IRIS BI Solutions Using Docker & VSCode (video) The Freedom of Visualization Choice: InterSystems BI (video) InterSystems BI(DeepSee) Overview (online course) InterSystems BI(DeepSee) Analyzer Basics (online course) Docker container usage - 2 points The application gets a 'Docker container' bonus if it uses InterSystems IRIS running in a docker container. Here is the simplest template to start from. ZPM Package deployment - 2 points You can collect the bonus if you build and publish the ZPM(InterSystems Package Manager) package for your Full-Stack application so it could be deployed with: zpm "install your-multi-model-solution" command on IRIS with ZPM client installed. ZPM client. Documentation. Online Demo of your project - 2 pointsCollect 2 more bonus points if you provision your project to the cloud as an online demo. You can do it on your own or you can use this template - here is an Example. Here is the video on how to use it. Unit Testing - 2 points Applications that have Unit Testing for the InterSystems IRIS code will collect the bonus. Learn more about ObjectScript Unit Testing in Documentation and on Developer Community. Article on Developer Community - 2 points Post an article on Developer Community that describes the features of your project and collect 2 points for the article. The Second article on Developer Community - 1 point You can collect one more bonus point for the second article or the translation regarding the application. The 3rd and more will not bring more points but the attention will all be yours. Code quality pass with zero bugs - 1 point Include the code quality Github action for code static control and make it show 0 bugs for ObjectScript. Video on YouTube - 3 points Make the Youtube video that demonstrates your product in action and collect 3 bonus points per each. The list of bonuses is subject to change. Stay tuned!
Question
Muhammad Waseem · May 16, 2022

InterSystems FHIR Server (FHIRaaS) API Error

Hi All, Since yesterday I am getting below error while calling InterSystems FHIR Server (FHIRaaS) API Looking ForwardThanks
Announcement
Anastasia Dyubaylo · Sep 10, 2022

[Video] Overview of Basic Components for InterSystems Integration Solutions

Hey Community, In this demonstration you will see the building blocks of an integration in InterSystems IRIS for Health and HealthShare and see how messages are received, processed, and sent—including messages in the HL7 format: ⏯ Overview of Basic Components for InterSystems Integration Solutions Don't miss the latest videos for InterSystems developers on our DC YouTube!
Announcement
Anastasia Dyubaylo · Aug 26, 2022

[Video] Using the Business Process Designer in InterSystems IRIS

Hey Developers, New video is already on InterSystems Developers YouTube channel: ⏯ Using the Business Process Designer in InterSystems IRIS See how to construct a new business process, which provides business logic and routing capabilities within an InterSystems production. Learn how to build a BPL business process using the Business Process Designer in the Management Portal. Also, try building one yourself using an InterSystems IDE. Enjoy watching!
Announcement
Anastasia Dyubaylo · Aug 30, 2022

[Video] Creating Complex Decision Logic with InterSystems IRIS

Hey Developers, Meet the new video on InterSystems Developers YouTube channel: ⏯ Creating Complex Decision Logic with InterSystems IRIS Using the graphical interface of the Business Rule Editor in InterSystems IRIS data platform, nontechnical users can set up business rules to better process records and untangle complex data. Like and share! Very helpful and nice use of features. I appreciate the real-world use case and thorough explanation!
Announcement
Anastasia Dyubaylo · Jun 19, 2022

[Video] InterSystems HealthShare Storage Footprint Reduction

Hey Developers, Join us for a discussion guide of current operational tasks to reduce storage and an overview of new features coming in InterSystems HealthShare 2021.2, including stream, database, and journal compression abilities: ⏯ InterSystems HealthShare Storage Footprint Reduction 🗣 Presenter: @Mark.Bolinsky, InterSystems Corporation Principle Technology Architect Enjoy watching on InterSystems Developers YouTube channel! Hi @Mark.Bolinsky , this is very useful and helpful for our China custs, and we'd really appreciate if you could help do an article for this becoz we Chinese users cannot access Youtube. Thx a lot for your big favor!
Announcement
Angelo Bruno Braga · Mar 11, 2022

1st InterSystems Portuguese Tech Article Contest

Hi Developers ! Welcome to our 🏆1st InterSystems Portuguese Tech Article Contest 🏆 Write an article about any topic related to InterSystems technologies from March 14 to April 14, 2022. We're excited about your participation. Join now! Build up a team and join sending the article made by the team. There will be a bonus for articles made by teams. Prizes for everybody: All participants will receive a special prize! Duration: from March 14 to April 14, 2022 Prizes 1. All are winners on our 1st InterSystems Portuguese Tech Article Contest! Any member that joins the contest will receive a special prize: 🎁 InterSystems - Developers Community termic bottle 2. Experts Awards – the articles will be judged by InterSystems experts: 🥇 1st place: iPad 🥈 2nd place: Gaming Chair 🥉 3rd place: JBL Gaming Headphone 3. Developers Community Award – article with the most likes. The winner will be able to choose one of the following prizes: 🎁 Alexa (echoDot 4) 🎁 Google Chromecast 🎁 Earphone Bluetooth Earbuds Basic Redmi Airdots 2 - Xiaomi Important: The author can only be awarded once per category (in total the author will win 2 prizes: one for Expert and one for the Community) In the event of a tie, the number of votes of the experts for the tied articles will be considered as a tie-breaking criterion. Who can participate? Any Developer Community member, except for InterSystems employees. Create an account! Contest Period 📝 March 14 - April 14: Publication of articles and voting time. Publish an article(s) throughout this period. DC members can vote for published articles with Likes – votes in the Community award. Note: The sooner you publish an article(s), the more time you will have to collect both Experts & Community votes. 🎉 April 25: Winners announcement. What are the requirements? ❗️ Any article written during the contest period and satisfying the requirements below will automatically enter the competition: The article must be in Portuguese The article must be related to InterSystems technology It should list the challenges encountered and/or the reason for choosing the theme. It cannot be a translation of an article already published in other communities. The article must be 100% new in the community. Article size: >1,000 characters (links and codes are not counted towards character limit). If the article is written in partnership, the names of the co-authors must be indicated and all must be members of the community. New community members must be registered: Create an account! What to write about? ❗️ You can choose any tech topic related to InterSystems technology. 🎯 NEW BONUS: If your article is on the topic from the list of the proposed topics, you will receive a bonus of 5 Expert votes (vs 1st place selected by an Expert = 3 votes). Here're some possible fields for choosing the article topic. These are just examples, you have the liberty to choose anything you want. # Topic Details 1 Embedded Python Introduction Use the new functionality available in IRIS 2021.2 that allows you to write SQL methods and procedures in Python. 2 How to do CI/CD with InterSystems IRIS – 3 Change Data Capture with Kafka Connect An example that shows how to set up Kafka Connect and export & import SQL data via the Kafka Connect JDBC connector. 4 Using %MDX and %KPI instead of Subject Area in IRIS Analytics – 5 Exporting to Excel using Python – 6 Integrating cloud services with productions Ex.: MS Azure Cognitive Services or Amazon Rekognition. 7 Working with IKO (InterSystems Kubernetes Operator) – 8 InterSystems on the cloud Bringing the InterSystems Platform to the Cloud 9 High availability of InterSystems environments on K8S Deploying microservices technology with InterSystems in high availability 10 Data Science shared workgroup setup with ECP There is a data server and each data scientist has a compute node on their desktop. Show the data is available when disconnected and syncs when you re-connect. 11 Cloud connectors Write an article on how to use cloud connectors to manage InterSystems IRIS applications on Amazon Webservice and use the connectors to access services. Input and Output Adapters for S3 (Amazon Storage Service) Output Adapter for Cloudwatch (Amazon Monitoring Services) Output Adapter for SNS (Amazon Notification Service) for messaging. 12 HealthShare How can the InterSystems HealthShare platform help institutions prevent disease and promote people's health? 13 IRIS for Health / FHIR How can FHIR protocol accelerate healthcare application development? 14 IRIS for Health How can a healthcare platform help institutions make decisions based on longitudinal patient information? 15 IAM – InterSystems API Manager Using API Manager to improve service publishing Note: Articles on the same topic from different authors are allowed. Feel free to submit your topic ideas in the comments to this post. 🎯 EXTRA BÔNUS: Format of the presentation of the content of the Article: besides publishing the article make an explanatory video (+ 1 vote) The number of features used/described in the article (+ 1 vote) Indication/participation of a person from outside the community in the co-authorship of the Article – with the aim of promoting/disseminating it to other professionals (+ 3 votes) Article with the most comments (+ 2 votes) Article by a new member in the community without partnership (+ 3 votes) Presentation of the architecture (logical model) with the solution/representation of the explored theme (+1 vote) We're waiting for your great articles! Good luck! Go go go!!! Developers! Don't miss the 1st InterSystems Portuguese Tech Article Contest ! Join the contest, make articles and win prizes!
Announcement
Raj Singh · Mar 30, 2022

InterSystems Language Server version 2.0.0

InterSystems is pleased to announce version 2.0.0 of the Language Server for VS Code. The Language Server augments the VS Code ObjectScript extension to provide better syntax coloring, embedded documentation, code completion and more. Detailed information is available in the GitHub repo's README. Version 2.0.0 adds support for a number of new platform architectures including M1 Macs! It also reduces package size, improves SQL coloring, and fixes a number of other issues detailed in the CHANGELOG. As always, if you already have the extension installed, VS Code should automatically update your extension when you restart or reload. If you're a new user, use these instructions to get started.
Announcement
Anastasia Dyubaylo · Apr 6, 2022

InterSystems at "J On The Beach" International Conference in Málaga, Spain

Hey Developers, Good news! One more upcoming in-person event is nearby. We're pleased to invite you to join "J On The Beach", an international rendezvous for developers and DevOps around Big Data technologies. A fun conference to learn and share the latest experiences, tips & tricks related to Big Data technologies, and, the most important part, it’s On The Beach! 🗓 April 27-29, 2022 📍Málaga, Spain This year, InterSystems is a Gold Sponsor of the JOTB. We're more than happy to invite you and your colleagues to our InterSystems booth for a personal conversation. As always, there will be some surprises on it... 😁 In addition, on the first day of the Conference @David.Reche and @Eduardo.Anglada will give a talk called "Captain Kirk, exoplanet found on route using Auto Machine Learning. 🎯 More details can be found at jonthebeach.com Looking forward to seeing you soon!
Announcement
Anastasia Dyubaylo · Jul 11, 2022

InterSystems Full Stack Contest 2022: Voting time!

Hey Community, It's voting time! Let's cast your votes for the best applications in the InterSystems Full Stack Contest 2022: 🔥 VOTE FOR THE BEST APPS 🔥 How to vote? Details below. Experts nomination: InterSystems experienced jury will choose the best apps to nominate the prizes in the Experts Nomination. Please welcome our experts: ⭐️ @Andreas.Dieckow, Principal Product Manager⭐️ @Benjamin.DeBoe, Product Manager⭐️ @Robert.Kuszewski, Product Manager⭐️ @Raj.Singh5479, Product Manager⭐️ @Alexander.Koblov, Support Specialist⭐️ @Daniel.Kutac, Senior Sales Engineer⭐️ @Guillaume.Rongier7183, Sales Engineer⭐️ @Steve.Pisani, Senior Solution Architect⭐️ @Eduard.Lebedyuk, Senior Cloud Engineer⭐️ @Alexander.Woodhead, Technical Specialist⭐️ @Timothy.Leavitt, Development Manager ⭐️ @Jeffrey.Fried, Director of Product Management⭐️ @Evgeny.Shvarov, Developer Ecosystem Manager Community nomination: For each user, a higher score is selected from two categories below: Conditions Place 1st 2nd 3rd If you have an article posted on DC and an app uploaded to Open Exchange (OEX) 9 6 3 If you have at least 1 article posted on DC or 1 app uploaded to OEX 6 4 2 If you make any valid contribution to DC (posted a comment/question, etc.) 3 2 1 Level Place 1st 2nd 3rd VIP Global Masters level or ISC Product Managers 15 10 5 Ambassador GM level 12 8 4 Expert GM level or DC Moderators 9 6 3 Specialist GM level 6 4 2 Advocate GM level or ISC Employees 3 2 1 Blind vote! The number of votes for each app will be hidden from everyone. Once a day we will publish the leaderboard in the comments to this post. The order of projects on the contest page will be as follows: the earlier an application was submitted to the competition, the higher it will be in the list. P.S. Don't forget to subscribe to this post (click on the bell icon) to be notified of new comments. To take part in the voting, you need: Sign in to Open Exchange – DC credentials will work. Make any valid contribution to the Developer Community – answer or ask questions, write an article, contribute applications on Open Exchange – and you'll be able to vote. Check this post on the options to make helpful contributions to the Developer Community. If you changed your mind, cancel the choice and give your vote to another application! Support the application you like! Note: contest participants are allowed to fix the bugs and make improvements to their applications during the voting week, so don't miss and subscribe to application releases! Since the beginning of the voting we have the results: Expert Nomination, Top 3 Kozo by @Sean.Connelly iris-climate-change by @Muhammad.Waseem Carbon Footprint Counter by @Yuri.Gomes ➡️ Voting is here. Community Nomination, Top 3 iris-climate-change by @Muhammad.Waseem Carbon Footprint Counter by @Yuri.Gomes interoperability-manager by @Oliver.Wilms ➡️ Voting is here. So, the voting continues. Please support the application you like! Here are the results after 2 days of voting: Expert Nomination, Top 3 Kozo by @Sean Connelly iris-climate-change by @Muhammad Waseem interoperability-manager by @Oliver.Wilms Carbon Footprint Counter by @Yuri.Gomes World ice level by @Oleh.Dontsov ➡️ Voting is here. Community Nomination, Top 3 iris-climate-change by @Muhammad Waseem interoperability-manager by @Oliver.Wilms Carbon Footprint Counter by @Yuri Marx Kozo by @Sean Connelly World ice level by @Oleh.Dontsov ➡️ Voting is here. So, the voting continues. Please support the application you like! Devs! Here are the top 5 for now: Expert Nomination, Top 3 Kozo by @Sean Connelly iris-climate-change by @Muhammad Waseem interoperability-manager by @Oliver Wilms iris-for-money by @Oliver.Wilms Carbon Footprint Counter by @Yuri Marx ➡️ Voting is here. Community Nomination, Top 3 iris-climate-change by @Muhammad Waseem interoperability-manager by @Oliver Wilms iris-for-money by @Oliver.Wilms Carbon Footprint Counter by @Yuri Marx Arctic sea ice viewer by @Oleh.Dontsov ➡️ Voting is here. Voting for the InterSystems Full Stack Contest 2022 goes ahead! And here're the results at the moment: Expert Nomination, Top 3 iris-climate-change by @Muhammad Waseem Kozo by @Sean Connelly Carbon Footprint Counter by @Yuri Marx Arctic sea ice viewer by @Oleh Dontsov interoperability-manager by @Oliver Wilms ➡️ Voting is here. Community Nomination, Top 3 iris-climate-change by @Muhammad Waseem Arctic sea ice viewer by @Oleh Dontsov interoperability-manager by @Oliver Wilms Carbon Footprint Counter by @Yuri Marx Kozo by @Sean Connelly ➡️ Voting is here. Developers! Last call!Only a few hours left to the end of voting! Cast your votes for applications you like!
Announcement
Anastasia Dyubaylo · Jul 18, 2022

Online Meetup with InterSystems Full Stack Contest Winners

Hi Community, Let's meet together at the online meetup with the winners of the InterSystems Full Stack contest – a great opportunity to have a discussion with InterSystems Experts team as well as our contestants. Winners' demo included! Date & Time: Friday, July 22 – 12:00 PM EDT Join us to learn more about winners' applications and to have a talk with our experts. ➡️ REGISTER TODAY! See you at our virtual meetup! Hey Developers, Watch the recording of the meetup on InterSystems Developers YouTube: ⏯ Online Meetup with InterSystems Full Stack Contest Winners
Announcement
Anastasia Dyubaylo · Dec 27, 2021

2nd InterSystems Tech Article Contest: And the Winners are...

Hey everyone, Lots of new content to read! Thanks to our wonderful participants of the 2nd InterSystems Tech Article Contest! 🌟 25 AMAZING ARTICLES 🌟 So it's time to announce the best of them! Let's meet the winners and their articles: ⭐️ Expert Awards – winners selected by InterSystems experts: 🥇 1st place: Data anonymization, introducing iris-Disguise by @Henry.HamonPereira 🥈 2nd place: IntegratedML hands-on lab by @José.Pereira 🥉 3rd place and two winners: VSCode-ObjectScript on GitHub by @Dmitry.Maslennikov Invite the FHIR® Accelerator Service to your Kubernetes Microservice Party by @Ron.Sweeney1582 ⭐️ Community Award – winner selected by Community members, article with the most likes: 🏆 Data anonymization, introducing iris-Disguise by @Henry.HamonPereira Hope this win will be a great Christmas present for all of the winners! ⭐️ This time, we'd like to reward some more authors for the number of contributions: @Yuri.Gomes: 4 articles! @MikhailenkoSergey: 3 articles! These guys will get Apple AirPods Pro OR Amazon Kindle 8G Paperwhite OR Raspberry Pi 4 8GB with InterSystems IRIS Community Edition ARM installed! And... Let's congratulate all our heroes at https://community.intersystems.com/contests/2: @Robert.Cemper1003 @Henrique.GonçalvesDias @Muhammad.Waseem @Rob.Tweed @John.Murray @alex.kosinets @Irene.Mikhaylova @Oliver.Wilms @Rizmaan.Marikar2583 THANK YOU ALL! You have made an incredible contribution to our Dev Community! Happy Holidays to everyone! 🎅 The prizes are in production now. We will contact all the participants when they are ready to ship Thanks my reward and congrats for the participants, great articles! Congratulations everyone. Very impressive! ![yeee](https://media0.giphy.com/media/l4FGAREbOSRLKMiNq/giphy.gif) What a wonderful surprise!! Thank you all community and congratulations to all participants Congratulations all, and happy new year Congratulations to ALL. It was nice competition Congratulations to the authors :-) Thanks everybody!!! Congratulations! We're lucky to have airpods as the third place prize. Those were easy to split equally between the tied contestants :-) Congratulations! Well done everyone! And now we have beautiful badges for all the winners on Global Masters tied to levels - so these badges will help you to move up through GM levels! Congrats and Happy New Year! Dear participants, regarding prizes and swag delivery: we will be in touch with you at the beginning of January - shortly after the Holidays.
Article
José Pereira · Dec 27, 2021

Using Python to Implement an IMAP Client in InterSystems IRIS

In the previous articles, we learned the basics of using IMAP protocol to handle messages from mailboxes in an e-mail server. That was cool and interesting, but you could take advantage of implementations created by other ones, available in libraries ready to use. One of the improvements to the IRIS data platform is the ability to write Python code alongside ObjectScript in the same IRIS process. This new feature is called [Embedded Python](https://community.intersystems.com/post/start-learning-about-embedded-python). Embedded Python lets us bring to our ObjectScript code the power of the huge [Python ecosystem’s libraries](https://pypi.org/). In this article, we’ll use one of those libraries, called [imaplib](https://docs.python.org/3/library/imaplib.html), to implement an IMAP client and integrate it with the [IRIS Email Framework](https://community.intersystems.com/post/implementing-imap-client-intersystems-iris-part-ii). We’ll also review a practical example of how to use embedded Python to resolve real-world challenges on the IRIS platform with the help of the Python ecosystem. You can find all code implemented here in this GitHub [repository](https://github.com/jrpereirajr/iris-imap-inbound-adapter-demo), in the [python directory](https://github.com/jrpereirajr/iris-imap-inbound-adapter-demo/tree/main/src/dc/demo/imap/python). Note that Python code just works in recent IRIS versions. In this example, the used version was 2021.1.0.215.3-zpm. You can follow updates about Embedded Python [here](https://community.intersystems.com/tags/python). ## Using Embedded Python The key to using embedded Python is the class %SYS.Python. By using this class, we can: * Import Python libraries: `##class(%SYS.Python).Import(“package-name”)` * Import custom Python modules (*.py files) available into the local system: `##class(%SYS.Python).Import(“module-file.py”)` * Get some Python built-in types to be used in assignments or parameters, for instance: * Python None object: `##class(%SYS.Python).None()` * Python True object: `##class(%SYS.Python).True()` * Python False object: `##class(%SYS.Python).False()` * Convert ObjectScript strings to Python Bytes objects (8-bit strings): `##class(%SYS.Python).Bytes(“ObjectScript string”)` These methods create Python objects and return an ObjectScript object. We can use the Python object’s properties and methods directly in our ObjectScript code. For instance, let’s see how we can implement this Python [recipe](https://docs.python.org/3/library/secrets.html#recipes-and-best-practices) for using the secrets library to generate passwords: USER>Set string = ##class(%SYS.Python).Import("string") USER>Set secrets = ##class(%SYS.Python).Import("secrets") USER>ZWrite secrets // let's check what this object is... secrets=1@%SYS.Python ; ; USER>ZWrite string // same for this one... string=2@%SYS.Python ; ; USER>Set alphabet = string."ascii_letters" _ string.digits // here we are accessing Python properties from string object USER>Set pwd = "" USER>For i=1:1:8 { Set pwd = pwd _ secrets.choice(alphabet) } USER>Write pwd Qv7HuOPV In this code, we use several properties and methods from Python objects to set ObjectScript variables. We use ObjectScript variables as parameters for Python objects methods. Another key point to using embedded Python is unique attributes and methods, sometimes called magical methods. Because everything in [Python data models](https://docs.python.org/3/reference/datamodel.html) are objects, these attributes and methods provide the Python interpreter's interface. For example, here’s how we retrieve an item from a list by its index, using the [\_\_getitem\_\_](https://docs.python.org/3/reference/datamodel.html#object.\_\_getitem\_\_) special method: USER>Set b = ##class(%SYS.Python).Import("builtins") USER>Set list = b.list() // creates a Python list USER>Do list.append(1) USER>Do list.append(2) USER>Do list.append(3) USER>ZWrite list list=4@%SYS.Python ; [1, 2, 3] ; USER>w list."__getitem__"(0) // in Python, indexes are 0-based 1 USER>w list."__getitem__"(2) 3 In the same way, we can get the length of the list by using the \_\_len\_\_ special method: USER>Set listLen = list."__len__"() USER>ZWrite listLen listLen=3 We can combine them to iterate the list using ObjectScript: USER>For i=0:1:(listLen - 1) { Write list."__getitem__"(i), ! } 1 2 3 If we need to use constant values like None, True, or False, we can use the following methods from the %SYS.Python class: USER>Set none = ##class(%SYS.Python).None() USER>Set true = ##class(%SYS.Python).True() USER>Set false = ##class(%SYS.Python).False() USER>ZWrite none, true, false none=5@%SYS.Python ; None ; true=6@%SYS.Python ; True ; false=7@%SYS.Python ; False ; Similarly, we can convert an ObjectScript string to a Python Bytes object: USER>Set bytes = ##class(%SYS.Python).Bytes("This is a string") USER>ZWrite bytes bytes=8@%SYS.Python ; b'This is a string' ; Finally, we define our custom Python modules and import them into the ObjectScript context. You can find more useful resources on how to use embedded Python [here](https://community.intersystems.com/tags/python). For instance, check out this nice [example](https://community.intersystems.com/post/websocket-client-embedded-python) by [Robert Cemper](https://community.intersystems.com/user/robert-cemper-0). ## Writing an Alternative IMAP Client To use imaplib to implement our IMAP client, we use the regular [ObjectScript](https://community.intersystems.com/post/implementing-imap-client-intersystems-iris-part-i). We override its methods with the imaplib methods instead of implementing the IMAP protocol from the beginning. First, we create a new class named dc.demo.imap.python.IMAPPy. This class uses two properties to store references to Python objects: Class dc.demo.imap.python.IMAPPy Extends dc.demo.imap.IMAP { /// Stores the imaplib object reference Property imaplib As %SYS.Python; /// Stores the imaplib client instance Property client As %SYS.Python; ... Next, we import the imaplib library into the ObjectScript context, in the class constructor: Method %OnNew() As %Status [ Private ] { Set ..imaplib = ##class(%SYS.Python).Import("imaplib") Return $$$OK } Now, we can access all imaplib properties and methods using the imaplib class property. The first method that we override was the Connect method. This method uses the imaplib IMAP4_SSL method to make a connection to the IMAP server. It stores the imaplib client instance as a client property. The login method of the imaplib client will authenticate login requests, as follows: Method Connect(pServer As %String, pUserName As %String, pPassword As %String) As %Status { If ..Connected Return $$$ERROR($$$ConnectedError) Set sc = $$$OK Try { Set ..Server = pServer Set ..UserName = pUserName Set ..client = ..imaplib."IMAP4_SSL"(..Server) Set resp = ..client.login(..UserName, pPassword) Set ..Connected = 1 } Catch ex { Set sc = ex.AsStatus() } Return sc } The next method we override is the Disconnect method. This method now calls the logout method from the imaplib client: Method Disconnect() As %Status { Set sc = $$$OK Try { If ..Connected { Set tuple = ..client.logout() Set ..Connected = 0 } } Catch ex { Set sc=ex.AsStatus() } Return sc } The method GetMailBoxStatus was overridden to use the select method from imaplib to specify which mailbox to access. Method GetMailBoxStatus(ByRef NumberOfMessages As %Integer, ByRef NumberOfBytes As %Integer) As %Status { Set sc = $$$OK Try { Do ..CheckConnection() Set resp = ..client.select(..MailboxName) Set ackToken = resp."__getitem__"(0) Set dataArray = resp."__getitem__"(1) Set NumberOfMessages = dataArray."__getitem__"(0) Set NumberOfBytes = -1 } Catch ex { Set sc=ex.AsStatus() } Return sc } Note that this method returns a tuple, so the special method \_\_getitem\_\_ allows us to retrieve information. Also, remember that a tuple can store another tuple, so we can recursively use \_\_getitem\_\_. The following method overridden was GetSizeOfMessages. This method now uses the select method to choose the current mailbox and the fetch method to get the size of the message stored in the MessageNumber parameter. Method GetSizeOfMessages(MessageNumber As %String = "", ByRef ListOfSizes As %ArrayOfDataTypes) As %Status { Set sc = $$$OK Try { Do ..CheckConnection() // select the mailbox Set resp = ..client.select(..MailboxName) // hack to ensure that MessageNumber is of type %String Set MessageNumber = MessageNumber_"" Set resp = ..client.fetch(MessageNumber, "(RFC822.SIZE)") Set ackToken = resp."__getitem__"(0) Set dataArray = resp."__getitem__"(1) Set:('$ISOBJECT($Get(ListOfSizes))) ListOfSizes = ##class(%ArrayOfDataTypes).%New() Set data = dataArray."__getitem__"(0) Set msgIdx = +$Piece(data, " ", 1) Set size = +$Piece(data, " ", 3) Do ListOfSizes.SetAt(size, msgIdx) } Catch ex { Set sc=ex.AsStatus() } Return sc } We override the GetMessageUIDArray method in the same way to use the fetch method, but now we use it to get the UID codes: Method GetMessageUIDArray(MessageNumber As %String = "", ByRef ListOfUniqueIDs As %ArrayOfDataTypes) As %Status { Set sc = $$$OK Try { Do ..CheckConnection() // select the mailbox Set resp = ..client.select(..MailboxName) Set mailboxSize = resp."__getitem__"(1)."__getitem__"(0) If (mailboxSize > 0) { // hack to ensure that MessageNumber is of type %String Set MessageNumber = MessageNumber_"" // then get the mailbox UIDs Set param = $CASE(MessageNumber, "":"1:*", :MessageNumber) Set resp = ..client.fetch(param, "UID") Set ackToken = resp."__getitem__"(0) Set dataArray = resp."__getitem__"(1) Set len = dataArray."__len__"() } Else { Set len = 0 } Set:('$ISOBJECT($Get(ListOfUniqueIDs))) ListOfUniqueIDs = ##class(%ArrayOfDataTypes).%New(len) For i = 1:1:len { Set data = dataArray."__getitem__"(i - 1) Set msgIdx = +$Piece(data, " ", 1) Set size = +$Piece(data, " ", 3) Do ListOfUniqueIDs.SetAt(size, msgIdx) } } Catch ex { Set sc=ex.AsStatus() } Return sc } Note the use of the \_\_getitem\_\_ and \_\_len\_\_ methods to iterate over the tuples in the dataArray variable: … Set len = dataArray."__len__"() … For i = 1:1:len { Set data = dataArray."__getitem__"(i - 1) Set msgIdx = +$Piece(data, " ", 1) Set size = +$Piece(data, " ", 3) Do ListOfUniqueIDs.SetAt(size, msgIdx) } Next, we override the Fetch method, which we use to retrieve the whole message body: Method Fetch(MessageNumber As %Integer, ByRef Msg As %Net.MailMessage, Delete As %Boolean, messageStream As %BinaryStream) As %Status { Set sc = $$$OK Try { Do ..CheckConnection() // select the mailbox Set resp = ..client.select(..MailboxName) // hack to ensure that MessageNumber is of type %String Set MessageNumber = MessageNumber_"" // get the whole message Set resp = ..client.fetch(MessageNumber, "BODY.PEEK[]") Set rawMsg = ..TransversePythonArray(resp."__getitem__"(1)) ... } Catch ex { Set sc=ex.AsStatus() } Return sc } Note the presence of the method TransversePythonArray. Because the message body returned by the fetch method is a composition of collections, we created this method to recursively transverse this collection and flatten it into a single string. ClassMethod TransversePythonArray(pArray As %SYS.Python) As %String { Set acc = "" If ($IsObject(pArray)) { Set len = pArray."__len__"() For i = 1:1:len { Set item = pArray."__getitem__"(i - 1) If ($IsObject(item)) { Set acc = acc_..TransversePythonArray(item) } Else { Set acc = acc_item } Set acc = acc_$Char(13, 10) } } Else { Set acc = pArray_$Char(13, 10) } Return acc } We also override the Ping method to use the imaplib noop method. Method Ping() As %Status { Set sc = $$$OK Try { Do ..CheckConnection() Set resp = ..client.noop() } Catch ex { Set sc=ex.AsStatus() } Return sc } The last method overridden was the CommitMarkedAsDeleted method. It now uses the methods store and expunge to mark messages for deletion and to commit such operations. Method CommitMarkedAsDeleted() As %Status [ Internal, Private ] { Set sc = $$$OK Try { Do ..CheckConnection() // select the mailbox Set resp = ..client.select(..MailboxName) // transverse array in inverse order to keep numbers integrity, // that is, ensures that when the number is deleted no other // message can assume such number Set messageNumber = $Order(..MarkedAsDeleted(""), -1) While (messageNumber '= "") { // hack to ensure that messageNumber is of type %String Set messageNumber = messageNumber_"" Set resp = ..client.store(messageNumber, "+FLAGS", "\Deleted") Set messageNumber = $Order(..MarkedAsDeleted(messageNumber), -1) } Kill ..MarkedAsDeleted Set resp = ..client.expunge() } Catch ex { Set sc=ex.AsStatus() } Return sc } ## Conclusion This method is much easier to implement compared to the original one, where we had to implement each IMAP command manually using IRIS TCP commands. Now that you’ve seen a good example of how we can use the rich Python library ecosystem for real-world problems, start powering up your ObjectScript applications! ## References * [imaplib — IMAP4 protocol client](https://docs.python.org/3/library/imaplib.html) * [Video: Embedded Python in InterSystems IRIS: Sneak Peek](https://community.intersystems.com/post/new-video-embedded-python-intersystems-iris-sneak-peek) * [Embedded Python: Bring the Python Ecosystem to Your ObjectScript App](https://learning.intersystems.com/course/view.php?id=1572) * [Learn Python Network Programming: Python - IMAP](https://www.tutorialspoint.com/python_network_programming/python_imap.htm) * [Python Documentation: Recipes and Best Practices](https://docs.python.org/3/library/secrets.html#recipes-and-best-practices) * [Python Documentation: Data Model](https://docs.python.org/3/reference/datamodel.html) * [WebSocket Client with Embedded Python](https://community.intersystems.com/post/websocket-client-embedded-python) * [InterSystems Developer Community: #Python](https://community.intersystems.com/tags/python) Hi, @José.Pereira! Ia it possible to build a ZPM module for the case? And publish it on Open Exchange?