diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e5cdb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,101 @@ +/dist +/images +/docs_src/build +/tests/images +/build +/bin +/seeq_causality.egg-info +/.spyproject +.idea +.ptest_cache +*.pyc +*.egg-info +*.egg + +log/ +*.log + +**/node_modules + +# OS clutter +*.DS_Store +**/Thumbs.db +.keep + +/target +/*/image + +*.zip +*.tar.gz + + +# Vim/Emacs old files +*~ + +# office temp files +~$* +~*.tmp + +# Eclipse settings +*.classpath +*.project +*.prefs +*.class + +# IntelliJ settings +.idea +*.iml + +# Visual Studio settings +.localhistory/ +Backup*/ +*.[Cc]ache +!*.[Cc]ache/ +*.e2e +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc +Generated\ Files/ +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates +.csv +*.xlsx +*.pdf + +# credential files +*.key \ No newline at end of file diff --git a/additional_content/LargeMatrixExample.png b/additional_content/LargeMatrixExample.png new file mode 100644 index 0000000..8b136d6 Binary files /dev/null and b/additional_content/LargeMatrixExample.png differ diff --git a/addon.json b/addon.json new file mode 100644 index 0000000..1936616 --- /dev/null +++ b/addon.json @@ -0,0 +1,66 @@ +{ + "identifier": "com.seeq.addon.correlation", + "name": "Correlation Analysis", + "description": "Determine cross correlations and time shifts to maximize correlations among signals", + "version": "Input version here", + "license": "Apache-2.0 license", + "icon": "fa fa-th", + "tags": {"maintainer":"Seeq"}, + "previews": [ + "additional_content/LargeMatrixExample.png" + ], + "elements": [ + { + "name": "Correlation Analysis", + "description": "Determine cross correlations and time shifts to maximize correlations among signals", + "identifier": "com.seeq.addon.correlation.correlation", + "type": "AddOnTool", + "path": "data-lab-functions", + "notebook_file_path": "correlation_analysis_master.ipynb", + "extensions": ["ipyvuetify", "widgetsnbextension","ipyvue"], + "configuration_schema": { + "type": "object", + "properties": { + "display": { + "type": "object", + "properties": { + "icon": { + "type": "string", + "default": "fa fa-th" + }, + "linkType": { + "enum": ["window", "tab", "none"], + "default": "window" + }, + "sortKey": { + "type": "string", + "default": "c" + }, + "windowDetails": { + "type": "string", + "default": "toolbar=0,location=0,left=800,top=400,height=1000,width=1400" + }, + "reuseWindow": { + "type": "boolean", + "default": true + }, + "includeWorkbookParameters": { + "type": "boolean", + "default": true + } + }, + "required": [ + "icon", + "linkType", + "sortKey", + "windowDetails", + "reuseWindow", + "includeWorkbookParameters" + ] + } + }, + "required": ["display"] + } + } + ] +} \ No newline at end of file diff --git a/build.py b/build.py new file mode 100644 index 0000000..0d12409 --- /dev/null +++ b/build.py @@ -0,0 +1,150 @@ +import sys +import os +import json +import zipfile +import pathlib +import shutil +import argparse +import subprocess +from pathlib import Path +from artifactory import ArtifactoryPath + +parser = argparse.ArgumentParser() +parser.add_argument( + '-d', '--distribute', + help='Upload the built files to their distribution channels.', + action='store_true' +) +parser.add_argument( + '-c', '--compile', + help='Produce a compiled version of the code in addition to the source version', + action='store_true' +) +parser.add_argument( + '-a', '--addon', + help='Produce a zipped version for installation through the addon manager.', + action='store_true' +) +args = parser.parse_args() + +# build the distribution +distribution_relative_dir = 'dist' +distribution_abs_dir = os.path.join(os.getcwd(), distribution_relative_dir) +if os.path.isdir(distribution_abs_dir): + shutil.rmtree(distribution_abs_dir) +build_command = ['python3.8', 'setup.py', 'bdist_wheel', + '-d', distribution_relative_dir, + f'--python-tag=py{sys.version_info.major}{sys.version_info.minor}'] +subprocess.run(build_command, cwd=os.getcwd()) +source_wheel = max( + [os.path.join(distribution_abs_dir, f) for f in os.listdir(distribution_abs_dir)], + key=os.path.getctime +) + +source_wheel_name = os.path.split(source_wheel)[-1] +version = source_wheel_name.split('-')[1] + +compiled_wheel = None +if args.compile: + print('Creating pyc file') + pyc_relative_dir = os.path.join(distribution_relative_dir, 'bin') + pyc_abs_dir = os.path.join(distribution_abs_dir, 'bin') + build_command = [sys.executable, 'setup.py', 'bdist_egg', + '-d', pyc_relative_dir, + '--exclude-source-files', + '-m', '+c'] + build_result = subprocess.run(build_command, cwd=os.getcwd(), capture_output=True, text=True) + wheel_command = ['wheel', 'convert', os.path.join(pyc_relative_dir, '*.egg'), '-d', pyc_relative_dir] + wheel_result = subprocess.run(wheel_command, cwd=os.getcwd(), capture_output=True, text=True) + + # move the pyc wheel file to the dist dir + path = Path('.') + wheel_file = list(path.glob('**/bin/*.whl'))[0] + wheel_file.rename(Path(wheel_file.parent.parent, wheel_file.name)) + compiled_wheel = os.path.join(wheel_file.parent.parent, wheel_file.name) + + # remove the bin dir + shutil.rmtree(pyc_abs_dir) + +addon_manager_artifacts = [] +if args.addon: + name = 'correlation' + print(f'Creating {name}.addon') + # Ensure output folder exists + bin = os.path.join(os.getcwd(), 'bin') + if not os.path.exists(bin): + os.makedirs(bin) + + with open('addon.json') as json_file: + parsed_json = json.load(json_file) + parsed_json['version'] = version + + addon = os.path.join(bin, f'{name}.addon') + addon_meta = os.path.join(bin, f'{name}.addonmeta') + + # Build addon + with zipfile.ZipFile(addon, 'w') as z: + z.write(source_wheel, arcname=os.path.join('data-lab-functions', source_wheel_name)) + z.writestr('data-lab-functions/requirements.txt', f"./{source_wheel_name}") + with z.open("addon.json", "w") as c: + c.write(json.dumps(parsed_json, indent=2).encode("utf-8")) + directory = pathlib.Path("./seeq/addons/correlation/deployment_notebook/") + for file in directory.rglob('*ipynb'): + z.write(file, arcname=os.path.join('data-lab-functions', file.name)) + directory = pathlib.Path("./additional_content/") + for file in directory.iterdir(): + z.write(file) + addon_manager_artifacts.append(addon) + # Build addonmeta + print(f'Creating {name}.addonmeta') + with zipfile.ZipFile(addon_meta, 'w') as z: + with z.open("addon.json", "w") as c: + c.write(json.dumps(parsed_json, indent=2).encode("utf-8")) + directory = pathlib.Path("./additional_content/") + for file in directory.iterdir(): + z.write(file) + addon_manager_artifacts.append(addon_meta) + + print('Successfully created.') + +if args.distribute: + + # THIS BLOCK OF CODE IS NO MORE IN USE BUT COULD LATER BE USED IN FUTURE PURPOSES + # if compiled_wheel is not None: + # print(f'Distributing compiled wheel {compiled_wheel} to pipy.seeq.com') + # command_distribute_compiled = \ + # ['twine', 'upload', + # '--repository-url', 'https://pypi.seeq.com', + # '-u', username, + # '-p', password, + # compiled_wheel] + # result = subprocess.run(' '.join(command_distribute_compiled)) + # if result.stderr: + # print(f'There was an error uploading the compiled version: {result.stderr}') + # + # print(f'Distributing source wheel {source_wheel} to pypi.seeq.com:8081') + # command_distribute_source = \ + # ['twine', 'upload', + # '--repository-url', 'https://pypi.seeq.com:8081', + # '-u', username, + # '-p', password, + # source_wheel] + # result = subprocess.run(' '.join(command_distribute_source)) + # if result.stderr: + # print(f'There was an error uploading the source version: {result.stderr}') + + if addon_manager_artifacts: + print(f'Distributing addon manager artifacts to seeq.jfrog.io') + api_key = os.getenv('JFROG_API_KEY') + for artifact in addon_manager_artifacts: + _, file = os.path.split(artifact) + path = ArtifactoryPath(f"https://seeq.jfrog.io/artifactory/seeq-add-ons-prod-local/Correlation/{file}", + apikey=api_key) + try: + path.deploy_file(artifact) + properties = path.properties + # Add identifier property + properties["identifier"] = "com.seeq.addon.correlation" + path.properties = properties + except Exception as e: + print(e) \ No newline at end of file diff --git a/docs/.buildinfo b/docs/.buildinfo index f9d667e..9d8e596 100644 --- a/docs/.buildinfo +++ b/docs/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 8c9883435912791d366ba286ccb3fd61 +config: 88a6b7e57b24bdbe7e73d954fc7a4080 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/_modules/index.html b/docs/_modules/index.html index 82b0b25..0fc361f 100644 --- a/docs/_modules/index.html +++ b/docs/_modules/index.html @@ -3,7 +3,7 @@ - Overview: module code — seeq-correlation 0.1.8 documentation + Overview: module code — seeq-correlation 0.1.9 documentation