omnata-plugin-runtime 0.3.23a69__py3-none-any.whl → 0.3.24a70__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1827,26 +1827,35 @@ def managed_outbound_processing(concurrency: int, batch_size: int):
1827
1827
  raise ValueError(
1828
1828
  "To use the managed_outbound_processing decorator, you must attach a sync request to the plugin instance (via the _sync_request property)"
1829
1829
  )
1830
- # if self._sync_request.api_limits is None:
1831
- # raise ValueError('To use the managed_outbound_processing decorator, API constraints must be defined. These can be provided in the response to the connect method')
1832
1830
  logger.info(f"Batch size: {batch_size}. Concurrency: {concurrency}")
1833
- if len(method_args) == 0:
1834
- raise ValueError(
1835
- "You must provide at least one method argument, and the first argument must be a DataFrame or DataFrame generator (from outbound_sync_request.get_records)"
1836
- )
1837
- first_arg = method_args[0]
1838
- #logger.info(first_arg.__class__.__name__)
1839
- if first_arg.__class__.__name__ == "DataFrame":
1840
- logger.info("managed_outbound_processing received a DataFrame")
1841
- elif hasattr(first_arg, "__next__"):
1842
- logger.info("managed_outbound_processing received an iterator function")
1843
- else:
1844
- raise ValueError(
1845
- f"The first argument to a @managed_outbound_processing method must be a DataFrame or DataFrame generator (from outbound_sync_request.get_records). Instead, a {first_arg.__class__.__name__} was provided."
1846
- )
1831
+
1832
+ dataframe_arg = None
1833
+ if 'dataframe' in method_kwargs:
1834
+ dataframe_arg = method_kwargs['dataframe']
1835
+ del method_kwargs['dataframe']
1836
+ if dataframe_arg.__class__.__name__ != "DataFrame":
1837
+ raise ValueError(
1838
+ f"The 'dataframe' named argument to the @managed_outbound_processing must be a DataFrame. Instead, a {dataframe_arg.__class__.__name__} was provided."
1839
+ )
1840
+
1841
+ elif 'dataframe_generator' in method_kwargs:
1842
+ dataframe_arg = method_kwargs['dataframe_generator']
1843
+ del method_kwargs['dataframe_generator']
1844
+ if not hasattr(dataframe_arg, "__next__"):
1845
+ raise ValueError(
1846
+ f"The 'dataframe_generator' named argument to the @managed_outbound_processing must be an iterator function. Instead, a {dataframe_arg.__class__.__name__} was provided."
1847
+ )
1848
+ # if the dataframe was provided as the first argument, we'll use that
1849
+ if dataframe_arg is None and len(method_args) > 0:
1850
+ dataframe_arg = method_args[0]
1851
+ if dataframe_arg.__class__.__name__ != "DataFrame" and not hasattr(dataframe_arg, "__next__"):
1852
+ raise ValueError(
1853
+ f"The first argument to a @managed_outbound_processing method must be a DataFrame or DataFrame generator (from outbound_sync_request.get_records). Instead, a {first_arg.__class__.__name__} was provided. Alternatively, you can provide these via the 'dataframe' or 'dataframe_generator' named arguments."
1854
+ )
1855
+ method_args = method_args[1:]
1847
1856
 
1848
1857
  # put the record iterator on the queue, ready for the first task to read it
1849
- fixed_size_generator = FixedSizeGenerator(first_arg, batch_size=batch_size)
1858
+ fixed_size_generator = FixedSizeGenerator(dataframe_arg, batch_size=batch_size)
1850
1859
  tasks:List[threading.Thread] = []
1851
1860
  logger.info(f"Creating {concurrency} worker(s) for applying records")
1852
1861
  # just in case
@@ -1862,7 +1871,7 @@ def managed_outbound_processing(concurrency: int, batch_size: int):
1862
1871
  i,
1863
1872
  fixed_size_generator,
1864
1873
  self._sync_request._thread_cancellation_token,
1865
- method_args[1:],
1874
+ method_args,
1866
1875
  method_kwargs,
1867
1876
  ),
1868
1877
  )
@@ -1987,22 +1996,21 @@ def managed_inbound_processing(concurrency: int):
1987
1996
  concurrency_to_use = 1 # disable concurrency when running in development mode, it interferes with pyvcr
1988
1997
  else:
1989
1998
  concurrency_to_use = concurrency
1990
- # if self._sync_request.api_limits is None:
1991
- # raise ValueError('To use the managed_inbound_processing decorator, API constraints must be defined. These can be provided in the response to the connect method')
1992
- if len(method_args) == 0:
1993
- raise ValueError(
1994
- "You must provide at least one method argument, and the first argument must be a list of StoredStreamConfigurations (from inbound_sync_request.streams)"
1995
- )
1996
- first_arg: List[StoredStreamConfiguration] = method_args[0]
1997
- logger.info(first_arg.__class__.__name__)
1998
- if first_arg.__class__.__name__ == "list":
1999
- logger.info("managed_inbound_processing received a list")
2000
- else:
2001
- raise ValueError(
2002
- f"The first argument to a @managed_inbound_processing method must be a list of StoredStreamConfigurations. Instead, a {first_arg.__class__.__name__} was provided."
2003
- )
1999
+ stream_list_arg: List[StoredStreamConfiguration] = None
2000
+ if 'streams' in method_kwargs:
2001
+ stream_list_arg = cast(List[StoredStreamConfiguration],method_kwargs['streams'])
2002
+ del method_kwargs['streams']
2003
+ if stream_list_arg is None and len(method_args) > 0:
2004
+ stream_list_arg = cast(List[StoredStreamConfiguration],method_args[0])
2005
+ if stream_list_arg.__class__.__name__ != "list":
2006
+ raise ValueError(
2007
+ f"The first argument to a @managed_inbound_processing method must be a list of StoredStreamConfigurations if the 'streams' named argument is not provided. Instead, a {stream_list_arg.__class__.__name__} was provided."
2008
+ )
2009
+ method_args = method_args[1:]
2010
+ if stream_list_arg is None:
2011
+ raise ValueError("You must provide a list of StoredStreamConfiguration objects to the method, either as the first argument or as a named argument 'streams'")
2004
2012
 
2005
- streams_list: List[StoredStreamConfiguration] = first_arg
2013
+ streams_list = stream_list_arg
2006
2014
  # create a queue full of all the streams to process
2007
2015
  streams_queue = queue.Queue()
2008
2016
  for stream in streams_list:
@@ -2022,7 +2030,7 @@ def managed_inbound_processing(concurrency: int):
2022
2030
  i,
2023
2031
  streams_queue,
2024
2032
  self._sync_request._thread_cancellation_token,
2025
- method_args[1:],
2033
+ method_args,
2026
2034
  method_kwargs,
2027
2035
  ),
2028
2036
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.3.23a69
3
+ Version: 0.3.24a70
4
4
  Summary: Classes and common runtime components for building and running Omnata Plugins
5
5
  Author: James Weakley
6
6
  Author-email: james.weakley@omnata.com
@@ -3,10 +3,10 @@ omnata_plugin_runtime/api.py,sha256=_N5ok5LN7GDO4J9n3yduXp3tpjmhpySY__U2baiygrs,
3
3
  omnata_plugin_runtime/configuration.py,sha256=7cMekoY8CeZAJHpASU6tCMidF55Hzfr7CD74jtebqIY,35742
4
4
  omnata_plugin_runtime/forms.py,sha256=pw_aKVsXSz47EP8PFBI3VDwdSN5IjvZxp8JTjO1V130,18421
5
5
  omnata_plugin_runtime/logging.py,sha256=bn7eKoNWvtuyTk7RTwBS9UARMtqkiICtgMtzq3KA2V0,3272
6
- omnata_plugin_runtime/omnata_plugin.py,sha256=EaGIQdq_gcmH2loTluTa0T3YxuUhDNZTQIItzYXtZxE,102783
6
+ omnata_plugin_runtime/omnata_plugin.py,sha256=N05RyAmud6a6BXXtzccFTvbPz4bjF1yFE92Vx6FiRnc,103346
7
7
  omnata_plugin_runtime/plugin_entrypoints.py,sha256=s-SrUnXaS6FaBq1igiJhcCB3Md_a6op-dp_g1H_55QU,27736
8
8
  omnata_plugin_runtime/rate_limiting.py,sha256=se6MftQI5NrVHaLb1hByPCgAESPQhkAgIG7KIU1clDU,16562
9
- omnata_plugin_runtime-0.3.23a69.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
- omnata_plugin_runtime-0.3.23a69.dist-info/METADATA,sha256=u_HhdrNMZOCVn0A9Lv-u9q3KnOmxvRlJLDFAHrU8si0,1604
11
- omnata_plugin_runtime-0.3.23a69.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
- omnata_plugin_runtime-0.3.23a69.dist-info/RECORD,,
9
+ omnata_plugin_runtime-0.3.24a70.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
+ omnata_plugin_runtime-0.3.24a70.dist-info/METADATA,sha256=qWHXnGRPpqyDfKDnXmgSFu3chfHRa4evj6apwWoCWpA,1604
11
+ omnata_plugin_runtime-0.3.24a70.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ omnata_plugin_runtime-0.3.24a70.dist-info/RECORD,,