<!-- 
RSS generated by JIRA (8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b) at Sat Feb 10 16:34:10 JST 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>PFS-JIRA</title>
    <link>https://pfspipe.ipmu.jp/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>8.3.4</version>
        <build-number>803005</build-number>
        <build-date>13-09-2019</build-date>
    </build-info>


<item>
            <title>[INSTRM-1323] Use context managers (&quot;with&quot;) as much as possible in db code.</title>
                <link>https://pfspipe.ipmu.jp/jira/browse/INSTRM-1323</link>
                <project id="10300" key="INSTRM">Instrument control development</project>
                    <description>&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;Pulled from INSTRM-1298&amp;#93;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Please use context managers as much as possible in any database code. Both sqlalchemy and pandas support them. For sqlalchemy I believe the link is &lt;a href=&quot;https://docs.sqlalchemy.org/en/14/orm/session_basics.html#using-a-sessionmaker&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://docs.sqlalchemy.org/en/14/orm/session_basics.html#using-a-sessionmaker&lt;/a&gt;&#160;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="16938">INSTRM-1323</key>
            <summary>Use context managers (&quot;with&quot;) as much as possible in db code.</summary>
                <type id="3" iconUrl="https://pfspipe.ipmu.jp/jira/secure/viewavatar?size=xsmall&amp;avatarId=10518&amp;avatarType=issuetype">Task</type>
                                            <priority id="10000" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/priorities/medium.svg">Normal</priority>
                        <status id="10001" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/statuses/generic.png" description="The assignee thinks that the issue is resolved, and it&apos;s being reviewed before merge/close">In Review</status>
                    <statusCategory id="4" key="indeterminate" colorName="yellow"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="arnaud.lefur">arnaud.lefur</assignee>
                                    <reporter username="cloomis">cloomis</reporter>
                        <labels>
                            <label>EngRun</label>
                    </labels>
                <created>Tue, 13 Jul 2021 19:55:57 +0000</created>
                <updated>Thu, 18 May 2023 05:45:18 +0000</updated>
                                                                            <component>spt_operational_database</component>
                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                <comments>
                            <comment id="21699" author="cloomis" created="Sat, 17 Jul 2021 22:02:46 +0000"  >&lt;p&gt;It appears that significant improvements were made to context manager support between sqlalchemy 1.3.something and 1.4.something &amp;#8211; that link does not apply to 1.3. We are running 1.3.20 at Subaru. &lt;/p&gt;

&lt;p&gt;The update would be clean (per &lt;tt&gt;mamba update sqalchemy&lt;/tt&gt;, only sqlalchemy and greenlet would be touched).&lt;/p&gt;

&lt;p&gt;If people are nervous we could clone the &lt;tt&gt;conda-ics&lt;/tt&gt; environment and update that for testing. I&apos;m running one now and will report back.&lt;/p&gt;

&lt;p&gt;[ Note: &lt;tt&gt;mamba update --dry-run sqlalchemy&lt;/tt&gt; took 15s and offered the current 1.4.21; &lt;tt&gt;conda update --dry-run sqlalchemy&lt;/tt&gt; took 5 &lt;b&gt;minutes&lt;/b&gt; and only offered 1.4.4. Both using the same repos. Someone&apos;s solver is wrong. ]&lt;/p&gt;
</comment>
                            <comment id="21768" author="cloomis" created="Mon, 2 Aug 2021 22:56:52 +0000"  >&lt;p&gt;I have run sqlalchemy 1.4.21 in a test conda environment for MCS testing, and it did not obviously break anything in mcs or fps. Can I update the version  in &lt;tt&gt;conda-ics&lt;/tt&gt;?&lt;/p&gt;</comment>
                            <comment id="21769" author="kiyoto.yabe" created="Tue, 3 Aug 2021 01:11:07 +0000"  >&lt;p&gt;I just updated the version and tested in my side and did not see any problems so far, so I think you can updete on the mountain.&lt;/p&gt;</comment>
                            <comment id="21774" author="cloomis" created="Tue, 3 Aug 2021 04:03:54 +0000"  >&lt;p&gt;Thanks. Done (actually, 1.4.22). I believe the following idiom (from the linked document) for the Opdb class should now work:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;# we can now construct a Session() and include begin()/commit()/rollback()
# at once
with self.session.begin() as session:
    session.add(some_object)
    session.add(some_other_object)
# commits the transaction, closes the session
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="21830" author="kiyoto.yabe" created="Wed, 18 Aug 2021 07:05:00 +0000"  >&lt;p&gt;I pushed a test implementation like this on the branch, but not sure if it&apos;s a right way so need a review.&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
def insert(self, tablename, dataframe): &#160;
    model = getattr(models, tablename)
    with self.session.begin() as s:
        s.session.bulk_insert_mappings(model, dataframe.to_dict(orient=&lt;span class=&quot;code-quote&quot;&gt;&quot;records&quot;&lt;/span&gt;))&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="30264" author="kiyoto.yabe" created="Fri, 24 Dec 2021 08:26:58 +0000"  >&lt;p&gt;Can we close this ticket? If the current opDB codes (at the summit) deal with this properly, I will check them and try to make them merged.&lt;/p&gt;</comment>
                            <comment id="30265" author="hassan" created="Fri, 24 Dec 2021 13:38:52 +0000"  >&lt;p&gt;&lt;a href=&quot;https://pfspipe.ipmu.jp/jira/secure/ViewProfile.jspa?name=kiyoto.yabe&quot; class=&quot;user-hover&quot; rel=&quot;kiyoto.yabe&quot;&gt;Kiyoto Yabe&lt;/a&gt; I think all opDB code (as well as other software) at the summit needs to be merged to master. So we should best close this ticket after the merge.&lt;/p&gt;</comment>
                            <comment id="30287" author="kiyoto.yabe" created="Thu, 6 Jan 2022 05:44:27 +0000"  >&lt;p&gt;I think now the current master branch is (almost) compatible with the summit change. Could somebody check at summit whether it works as we expected?&lt;/p&gt;</comment>
                            <comment id="31600" author="arnaud.lefur" created="Thu, 13 Oct 2022 17:16:13 +0000"  >&lt;p&gt;I did the most I could.&lt;br/&gt;
I haven&apos;t tested yet, but I&apos;ve mostly followed sqlalchemy prescription&lt;/p&gt;</comment>
                            <comment id="32069" author="hassan" created="Fri, 6 Jan 2023 14:31:27 +0000"  >&lt;p&gt;&lt;a href=&quot;https://pfspipe.ipmu.jp/jira/secure/ViewProfile.jspa?name=arnaud.lefur&quot; class=&quot;user-hover&quot; rel=&quot;arnaud.lefur&quot;&gt;arnaud.lefur&lt;/a&gt; is there any quick test you could do to close this ticket?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10500" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|zzsx5r:c</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10005" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="118">EngRun03</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10002" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Story Points</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                        </customfields>
    </item>
</channel>
</rss>