PIconnect icon indicating copy to clipboard operation
PIconnect copied to clipboard

Connecting to All Known Data Archive and Asset Framework Servers on Import

Open zslp2 opened this issue 2 years ago • 3 comments

Bug report

Description

On import of PIconnect.PIServer, _lookup_servers() in PIconnect/PI.py and PIconnect/PIAF.py iterate over and connect to each known Data Archive (DA) and Asset Framework (AF) Server respectively. I have +70 known DA servers (most geographically remote, many over a slow data link) and ~50 known AF servers (again most geographically remote, many over a slow data link). This causes package import to take several minutes.

To Reproduce

Steps to reproduce the behavior:

from PIconnect import PIServer

Expected behavior

Package loads without iterating over and connecting to each DA and AF server.

Possible solutions

I am not sure if PIconnect is iterating over and connecting to each DA and AF server for any specific reasons other than to (1) make the connection and (2) list the known databases for each AF server. Even making an automatic connection to the default DA and AF server in _lookup_default_server() is potentially unwanted overhead, since I am always connecting to a specific system through PIServer() or PIAFDatabase().

Since the behavior happens at import, I think the only way to control that behavior is through an environment variable to bypass calls to _lookup_servers() and _lookup_default_server(); however this is only a guess.

System

  • OS: [Windows]
  • Python version: [Python 3.11]
  • PIconnect version: [e.g. 0.10.6]

zslp2 avatar Oct 25 '23 07:10 zslp2

Hi @zslp2 , do you know how to get the datatype of a pi point? For example, "numeric type" "non-numeric-type"

tbonewmy avatar Nov 07 '23 14:11 tbonewmy

Seems that the raw_attributes dictionary might help.

SINUSOID = server.search("SINUSOID")[0] SINUSOID.raw_attributes.keys() dict_keys(['descriptor', 'exdesc', 'typicalvalue', 'engunits', 'zero', 'span', 'pointtype', 'pointsource', 'scan', 'excmin', 'excmax', 'excdev', 'shutdown', 'archiving', 'compressing', 'step', 'compmin', 'compmax', 'compdev', 'creationdate', 'creator', 'changedate', 'changer', 'displaydigits', 'location1', 'location2', 'location3', 'location4', 'location5', 'filtercode', 'squareroot', 'totalcode', 'convers', 'srcptid', 'instrumenttag', 'userint1', 'userint2', 'userreal1', 'userreal2', 'ptowner', 'ptgroup', 'ptaccess', 'ptsecurity', 'dataowner', 'datagroup', 'dataaccess', 'datasecurity', 'pointid', 'recno', 'future', 'ptclassname', 'ptclassid', 'ptclassrev', 'tag', 'sourcetag', 'digitalset', 'compdevpercent', 'excdevpercent']) SINUSOID.raw_attributes['pointtype'] <PIPointType.Float32: 12>

zslp2 avatar Nov 07 '23 17:11 zslp2

this automatic connection on import seemed to make sense to me when I first developed this package, but is seems to cause more trouble then that it provides convenience. In a future version this is definitely something I want to take out. The more people are using the package, the more assumptions from early development stages are proven incorrect ;-)

Hugovdberg avatar Apr 25 '24 08:04 Hugovdberg