sapiadapter 0.37.30__tar.gz → 1.1.0__tar.gz

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.
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: sapiadapter
3
+ Version: 1.1.0
4
+ Summary: A minimal package exposing run, defdata, and defmeta methods
5
+ Author: Zafar Iqbal
6
+ Author-email: zaf@sparc.space
7
+ Requires-Python: >=3.11,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Programming Language :: Python :: 3.15
14
+ Requires-Dist: requests (>=2.28.2,<3.0.0)
15
+ Description-Content-Type: text/markdown
16
+
17
+ sapiadapter v1.0.0
@@ -0,0 +1 @@
1
+ sapiadapter v1.0.0
@@ -0,0 +1,15 @@
1
+ [tool.poetry]
2
+ name = "sapiadapter"
3
+ version = "1.1.0"
4
+ description = "A minimal package exposing run, defdata, and defmeta methods"
5
+ authors = ["Zafar Iqbal <zaf@sparc.space>"]
6
+ readme = "README.md"
7
+ packages = [{ include = "sapiadapter" }]
8
+
9
+ [tool.poetry.dependencies]
10
+ python = "^3.11"
11
+ requests = "^2.28.2"
12
+
13
+ [build-system]
14
+ requires = ["poetry-core"]
15
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,35 @@
1
+
2
+ import requests
3
+
4
+ __version__ = "1.1.0"
5
+
6
+ __all__ = [ "run" , "defdata" , "defmeta" ]
7
+
8
+ DATA = None
9
+
10
+ def run( url = None , params = None ) :
11
+
12
+ if not url : raise "url params None"
13
+ if not params : raise "run params None"
14
+
15
+ #url = ""
16
+
17
+ try :
18
+ response = requests.post( url , json = params , timeout = ( 5 , 30 ) , )
19
+ response.raise_for_status( )
20
+ except requests.exceptions.ConnectTimeout as exc : print( "ConnectTimeout" )
21
+ except requests.exceptions.ReadTimeout as exc : print( "ReadTimeout" )
22
+ except requests.exceptions.HTTPError as exc :
23
+ print( f"HTTPError {exc}" )
24
+ #"status_code": exc.response.status_code,
25
+ except requests.exceptions.RequestException as exc : print( f"RequestException {exc}" )
26
+
27
+ try : body = response.json( )
28
+ except ValueError : body = response.text
29
+
30
+ global DATA
31
+ DATA = body
32
+
33
+ def defmeta( ) : return( DATA[ "_meta" ] )
34
+
35
+ def defdata( ) : return( DATA[ "_data" ] )
@@ -1,14 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: sapiadapter
3
- Version: 0.37.30
4
- Summary:
5
- Author: Zafar Iqbal
6
- Author-email: zaf@sparc.space
7
- Requires-Python: >=3.9,<3.11
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: Programming Language :: Python :: 3.9
10
- Classifier: Programming Language :: Python :: 3.10
11
- Requires-Dist: requests (>=2.28.1,<3.0.0)
12
- Description-Content-Type: text/markdown
13
-
14
-
File without changes
@@ -1,15 +0,0 @@
1
- [tool.poetry]
2
- name = "sapiadapter"
3
- version = "0.37.30"
4
- description = ""
5
- authors = ["Zafar Iqbal <zaf@sparc.space>"]
6
- readme = "README.md"
7
-
8
- [tool.poetry.dependencies]
9
- python = "^3.9,<3.11"
10
- requests = "^2.28.1"
11
-
12
-
13
- [build-system]
14
- requires = ["poetry-core"]
15
- build-backend = "poetry.core.masonry.api"
@@ -1,32 +0,0 @@
1
-
2
- #####################################################################
3
- # ___ ___ ___
4
- # / /\ / /\ / /\ ___
5
- # / /:/_ / /::\ / /::\ / /\
6
- # / /:/ /\ / /:/\:\ / /:/\:\ / /:/
7
- # / /:/ /::\ / /:/~/::\ / /:/~/:/ /__/::\
8
- # /__/:/ /:/\:\ /__/:/ /:/\:\ /__/:/ /:/ \__\/\:\__
9
- # \ \:\/:/~/:/ \ \:\/:/__\/ \ \:\/:/ \ \:\/\
10
- # \ \::/ /:/ \ \::/ \ \::/ \__\::/
11
- # \__\/ /:/ \ \:\ \ \:\ /__/:/
12
- # /__/:/ \ \:\ \ \:\ \__\/
13
- # \__\/ \__\/ \__\/
14
- #
15
- # Project : SAPIADAPTER
16
- # Author(s) : Zafar Iqbal < zaf@sparc.space >
17
- # Copyright : (C) 2022 SPARC PC < https://sparc.space/ >
18
- #
19
- # All rights reserved. No warranty, explicit or implicit, provided.
20
- # SPARC PC is and remains the owner of all titles, rights
21
- # and interests in the Software.
22
- #
23
- #####################################################################
24
-
25
- __version__ = "0.37.30"
26
-
27
- #####################################################################
28
-
29
- def get_version( ) :
30
- return __version__
31
-
32
-
@@ -1,64 +0,0 @@
1
-
2
- #####################################################################
3
- #
4
- # s_cache.py
5
- #
6
- # Project : SAPIADAPTER
7
- # Author(s) : Zafar Iqbal < zaf@sparc.space >
8
- # Copyright : (C) 2022 SPARC PC < https://sparc.space/ >
9
- #
10
- # All rights reserved. No warranty, explicit or implicit, provided.
11
- # SPARC PC is and remains the owner of all titles, rights
12
- # and interests in the Software.
13
- #
14
- # FIXME TODO - log rotation/retention to not overflow disk space
15
- #
16
- #####################################################################
17
-
18
- import os
19
- from . import s_log , s_util
20
-
21
- #####################################################################
22
-
23
- # FIXME TODO use dynamic subfolders to avoid large number of files in single directory
24
-
25
- # FIXME TODO should be coming from config otherwise default
26
- cache_dirpath = "/tmp/sapiadapter/cache/"
27
-
28
- def available_for_inputs( inputs ) :
29
-
30
- # FIXME TODO group duplicated code
31
- inputs_str = s_util.json_dumps( inputs )
32
- #cache_hash = s_util.hash( inputs_str.encode( "utf-8" ) )
33
- cache_hash = s_util.hash( inputs_str )
34
- cache_filepath = cache_dirpath + cache_hash + ".json"
35
- s_log.write( "cache_filepath=" + cache_filepath )
36
-
37
- return os.path.isfile( cache_filepath )
38
-
39
- def set_inputoutput( inputs , outputs ) :
40
- # FIXME TODO group duplicated code
41
- inputs_str = s_util.json_dumps( inputs )
42
- #cache_hash = s_util.hash( inputs_str.encode( "utf-8" ) )
43
- cache_hash = s_util.hash( inputs_str )
44
- cache_filepath = cache_dirpath + cache_hash + ".json"
45
- if( os.path.isfile( cache_filepath ) ) : return( None )
46
- init_path( cache_filepath )
47
- response = outputs.copy( )
48
- s_util.json_save( cache_filepath , response )
49
- s_log.write( "cache updated" )
50
-
51
- def get_inputoutput( inputs ) :
52
- # FIXME TODO group duplicated code
53
- inputs_str = s_util.json_dumps( inputs )
54
- #cache_hash = s_util.hash( inputs_str.encode( "utf-8" ) )
55
- cache_hash = s_util.hash( inputs_str )
56
- cache_filepath = cache_dirpath + cache_hash + ".json"
57
- return( s_util.json_load( cache_filepath ) )
58
-
59
- def init_path( fp ) :
60
-
61
- fpdirname = os.path.dirname( fp )
62
-
63
- if( not os.path.isdir( fpdirname ) ) :
64
- os.makedirs( fpdirname , exist_ok = True )
@@ -1,34 +0,0 @@
1
-
2
- #####################################################################
3
- #
4
- # s_cleanup.py
5
- #
6
- # Project : SAPIADAPTER
7
- # Author(s) : Zafar Iqbal < zaf@sparc.space >
8
- # Copyright : (C) 2022 SPARC PC < https://sparc.space/ >
9
- #
10
- # All rights reserved. No warranty, explicit or implicit, provided.
11
- # SPARC PC is and remains the owner of all titles, rights
12
- # and interests in the Software.
13
- #
14
- #####################################################################
15
-
16
- import atexit
17
-
18
- #####################################################################
19
-
20
- from . import s_log , s_db
21
-
22
- #####################################################################
23
-
24
- def cleanup( ) :
25
- # FIXME TODO only delete the threads db! otherwise another process could be still running! not all
26
- # FIXME TOOD count how db files are in dir and report back!
27
- s_db.filepath_delete( )
28
- #s_log.write( "cleanup" )
29
- pass
30
-
31
- #####################################################################
32
-
33
- atexit.register( cleanup )
34
-