Skip to content

Commit

Permalink
Merge pull request #36 from seeq12/develop
Browse files Browse the repository at this point in the history
Merge Develop into master
  • Loading branch information
jameshiggie authored Oct 27, 2023
2 parents be40f51 + dae5efb commit a2d9817
Show file tree
Hide file tree
Showing 44 changed files with 548 additions and 64 deletions.
101 changes: 101 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Binary file added additional_content/LargeMatrixExample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions addon.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
]
}
150 changes: 150 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion docs/.buildinfo
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions docs/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &mdash; seeq-correlation 0.1.8 documentation</title>
<title>Overview: module code &mdash; seeq-correlation 0.1.9 documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand All @@ -26,7 +26,7 @@
<a href="../index.html" class="icon icon-home"> seeq-correlation
</a>
<div class="version">
0.1.8
0.1.9
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
Expand Down
4 changes: 2 additions & 2 deletions docs/_modules/seeq/addons/correlation/__main__.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>seeq.addons.correlation.__main__ &mdash; seeq-correlation 0.1.8 documentation</title>
<title>seeq.addons.correlation.__main__ &mdash; seeq-correlation 0.1.9 documentation</title>
<link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand All @@ -26,7 +26,7 @@
<a href="../../../../index.html" class="icon icon-home"> seeq-correlation
</a>
<div class="version">
0.1.8
0.1.9
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>seeq.addons.correlation._cross_correlations &mdash; seeq-correlation 0.1.8 documentation</title>
<title>seeq.addons.correlation._cross_correlations &mdash; seeq-correlation 0.1.9 documentation</title>
<link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand All @@ -26,7 +26,7 @@
<a href="../../../../index.html" class="icon icon-home"> seeq-correlation
</a>
<div class="version">
0.1.8
0.1.9
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get">
Expand Down
Loading

0 comments on commit a2d9817

Please sign in to comment.