Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ clean:
rm -rf ./build
rm -rf ./docs/_build
rm -rf ./dist
rm -rf ./cortex_python.egg-info
rm -rf ./cortex-python.docs.tgz
rm -rf ./sensa_python.egg-info
rm -rf ./sensa-python.docs.tgz

dev.install:
pip install -r requirements-dev.txt
Expand All @@ -21,7 +21,7 @@ else
build: build.release
endif
docker:
docker build -t c12e/cortex-python .
docker build -t c12e/sensa-python .

build.alpha: clean
python setup.py egg_info --tag-build a$(shell \
Expand All @@ -41,8 +41,8 @@ build.release: clean
python setup.py sdist bdist_wheel

dev.test:
pylint --recursive=y cortex
pytest --cache-clear --html=coverage/test-report.html --self-contained-html --cov=cortex/ --cov-report=html:coverage --cov-report=term test/unit
pylint --recursive=y sensa
pytest --cache-clear --html=coverage/test-report.html --self-contained-html --cov=sensa/ --cov-report=html:coverage --cov-report=term test/unit

test:
tox -r # tox runs make dev.test internally
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ The Cortex Python module provides an API client library to easily integrate with
Refer to the Cortex documentation for details on how to use the library:

- Developer guide: https://cognitivescale.github.io/cortex-fabric/
- Cortex Python references: https://cognitivescale.github.io/cortex-python/master/
- Cortex Python references: https://cognitivescale.github.io/sensa-python/master/

## Installation

To install:
```
> pip install cortex-python
> pip install sensa-python
```

or from source code:
```
> git clone git@github.com:CognitiveScale/cortex-python.git
> cd cortex-python
> git clone git@github.com:CognitiveScale/sensa-python.git
> cd sensa-python
> pip install -e .
```

To install the optional components:
```
> pip install cortex-python[viz]
> pip install cortex-python[jupyter]
> pip install sensa-python[viz]
> pip install sensa-python[jupyter]
```

## Development
Expand All @@ -39,8 +39,8 @@ When developing, it's a best practice to work in a virtual environment. Create a
Install developer dependencies:

```
> git clone git@github.com:CognitiveScale/cortex-python.git
> cd cortex-python
> git clone git@github.com:CognitiveScale/sensa-python.git
> cd sensa-python
> make dev.install
```

Expand Down Expand Up @@ -70,7 +70,7 @@ To run an individual file or class method, use pytest. Example tests shown below
Suppose you want to release new functionality so it can be installed without releasing a new official version. We need to use an alpha version in PyPi.

- we need to create and publish an alpha release:
- get credentials to the `cortex-python` pypi CognitiveScale account (via lastpass)
- get credentials to the `sensa-python` pypi CognitiveScale account (via lastpass)
- run `make dev.push`. The alpha pre-release number (the N in X.Y.ZaN) with be determined automatically.

### Contribution
Expand Down Expand Up @@ -120,4 +120,4 @@ The documentation will be rendered in HTML format under the `docs/_build/${VERSI
- [ ] Update all documentation with proper Sphinx formatting
- [x] Most of the major modules have been fixed except skill.py, model.py
- [x] use exceptions defined in `cortex/exceptions.py`
- [ ] integrate the cortex-python-profiles package back into the python SDK
- [ ] integrate the sensa-python-profiles package back into the python SDK
32 changes: 16 additions & 16 deletions cortex-python.gocd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ common:
coverage: testoutput/coverage/index.html
test-report: testoutput/coverage/test-report.html
pipelines:
cortex-python-pr:
sensa-python-pr:
group: pull-requests
materials:
cortex-python:
sensa-python:
plugin_configuration:
id: github.pr
version: 1
options:
url: git@github.com:CognitiveScale/cortex-python.git
url: git@github.com:CognitiveScale/sensa-python.git
defaultBranch: develop
environment_variables:
ALPHA_BUILD: "true"
Expand All @@ -28,11 +28,11 @@ pipelines:
elastic_profile_id: gocd-test-agent-dind
tasks:
- script: c12e-ci -l
cortex-python-develop:
sensa-python-develop:
group: fabric6
materials:
cortex-python:
git: git@github.com:CognitiveScale/cortex-python.git
sensa-python:
git: git@github.com:CognitiveScale/sensa-python.git
branch: develop
environment_variables:
ALPHA_BUILD: "true"
Expand All @@ -51,7 +51,7 @@ pipelines:
set -eux
git clone git@github.com:CognitiveScale/gocd-pipeline-scripts.git
./gocd-pipeline-scripts/common/c12e-common.sh dev
cortex-python-staging:
sensa-python-staging:
group: fabric6
environment_variables:
ALPHA_BUILD: "true"
Expand All @@ -62,8 +62,8 @@ pipelines:
# LastPass: Shared-devops/Pypi
REPO_PASSWORD: "AES:VK48nn/zr+mFTMixYa8Psg==:P+AZlJmgChiMcFRyNRmjuwYqBQwkc1hRP8zHck5L5SU="
materials:
cortex-python:
git: git@github.com:CognitiveScale/cortex-python.git
sensa-python:
git: git@github.com:CognitiveScale/sensa-python.git
branch: staging
stages:
- build:
Expand All @@ -77,7 +77,7 @@ pipelines:
git clone git@github.com:CognitiveScale/gocd-pipeline-scripts.git
./gocd-pipeline-scripts/common/c12e-common.sh staging
./gocd-pipeline-scripts/cortex5/python/publish-distribution.sh -i -e
cortex-python-master:
sensa-python-master:
group: fabric6
environment_variables:
ALPHA_BUILD: "false"
Expand All @@ -88,8 +88,8 @@ pipelines:
# LastPass: Shared-devops/Pypi
REPO_PASSWORD: "AES:VK48nn/zr+mFTMixYa8Psg==:P+AZlJmgChiMcFRyNRmjuwYqBQwkc1hRP8zHck5L5SU="
materials:
cortex-python-master:
git: git@github.com:CognitiveScale/cortex-python.git
sensa-python-master:
git: git@github.com:CognitiveScale/sensa-python.git
branch: main
stages:
- build:
Expand All @@ -100,7 +100,7 @@ pipelines:
elastic_profile_id: gocd-test-agent-dind
artifacts:
- build:
source: cortex-python.docs.tgz
source: sensa-python.docs.tgz
- test:
source: coverage
tasks:
Expand All @@ -118,11 +118,11 @@ pipelines:
elastic_profile_id: gocd-test-agent-dind
tasks:
- fetch:
pipeline: cortex-python-master
pipeline: sensa-python-master
stage: build
job: build
source: cortex-python.docs.tgz
source: sensa-python.docs.tgz
is_file: yes
- script: |
git clone git@github.com:CognitiveScale/gocd-pipeline-scripts.git
./gocd-pipeline-scripts/common/publish-gh-pages.sh -d cortex-python.docs.tgz -r git@github.com:CognitiveScale/cortex-python.git -b ${GH_PAGES_BRANCH} -k .nojekyll
./gocd-pipeline-scripts/common/publish-gh-pages.sh -d sensa-python.docs.tgz -r git@github.com:CognitiveScale/sensa-python.git -b ${GH_PAGES_BRANCH} -k .nojekyll
11 changes: 0 additions & 11 deletions cortex/__version__.py

This file was deleted.

4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<html>
<head>
<title>Cortex Python</title>
<meta http-equiv = "refresh" content="0; url='/cortex-python/master'" />
<meta http-equiv = "refresh" content="0; url='/sensa-python/master'" />
</head>
<body>
<p>Please wait while you're redirected to our <a href="/cortex-python/master">documentation</a>.</p>
<p>Please wait while you're redirected to our <a href="/sensa-python/master">documentation</a>.</p>
</body>
</html>
8 changes: 4 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ See the `Cortex Fabric documentation. <https://cognitivescale.github.io/cortex-f
Cortex Python Builders
------------------------

The cortex-python-builders library is an add-on library for use with the base cortex-python library that helps with building actions and skills.
The sensa-python-builders library is an add-on library for use with the base sensa-python library that helps with building actions and skills.
Copy link
Contributor

@laguirre-cs laguirre-cs Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more of a product question, but do we know what the plan is for these two (extension) packages? Are we going to deprecate or update (rename):

  • cortex-python-builders
  • cortex-python-profiles <--- I would presume this is to be functionally replaced by the Profiles SDK

Is there a backlog issue to address these packages? If not, then we should spin that off


See the `Cortex Python Builders Reference documentation. <https://cognitivescale.github.io/cortex-python-builders>`_
See the `Cortex Python Builders Reference documentation. <https://cognitivescale.github.io/sensa-python-builders>`_

Cortex Python Profiles
-------------------------

The cortex-python-profiles library is an add-on for use with the base cortex-python library that helps with building and managing Profile-of-One profiles and schemas.
The sensa-python-profiles library is an add-on for use with the base sensa-python library that helps with building and managing Profile-of-One profiles and schemas.

See the `Cortex Python Profiles Reference documentation. <https://cognitivescale.github.io/cortex-python-profiles>`_
See the `Cortex Python Profiles Reference documentation. <https://cognitivescale.github.io/sensa-python-profiles>`_

2 changes: 1 addition & 1 deletion docs/requirements-docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ sphinx-rtd-theme==1.0.0
sphinxcontrib-restbuilder==0.3
nbconvert==6.5.3

## This is a dependency from cortex-python (pre-v6.1.0) that was removed, but it must be installed in the environment
## This is a dependency from sensa-python (pre-v6.1.0) that was removed, but it must be installed in the environment
## to build docs for earlier versions of the library.
##pyjwt>=1.6.1,<2
2 changes: 1 addition & 1 deletion local/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Setup proxy with script to intercept internal API calls

Follow [this](https://docs.mitmproxy.org/stable/overview-installation/#installation-from-the-python-package-index-pypi) to install mitmproxy using pipx to be able to run scripts with cortex-python library
Follow [this](https://docs.mitmproxy.org/stable/overview-installation/#installation-from-the-python-package-index-pypi) to install mitmproxy using pipx to be able to run scripts with sensa-python library

Run mitmproxy with the proxy [python script](proxy_cortex_internal.py)

Expand Down
8 changes: 4 additions & 4 deletions local/proxy_cortex_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""

from mitmproxy import http
from cortex.client import Cortex
from sensa.client import Sensa
import json
import re
import os
Expand Down Expand Up @@ -51,7 +51,7 @@


def request(flow: http.HTTPFlow) -> None:
if "cortex.svc.cluster.local" in flow.request.pretty_url:
if "sensa.svc.cluster.local" in flow.request.pretty_url:
if "/internal" in flow.request.pretty_url:
if "/connections" in flow.request.pretty_url:
try:
Expand All @@ -63,7 +63,7 @@ def request(flow: http.HTTPFlow) -> None:
cortex_project = re.search(
"/projects/(.*)/connections/", flow.request.pretty_url
).group(1)
client = Cortex.client(
client = Sensa.client(
api_endpoint=cortex_endpoint,
project=cortex_project,
token=cortex_token,
Expand Down Expand Up @@ -127,5 +127,5 @@ def request(flow: http.HTTPFlow) -> None:
)
else:
flow.request.url = flow.request.pretty_url.replace(
"http://cortex-internal.cortex.svc.cluster.local", cortex_endpoint
"http://cortex-internal.sensa.svc.cluster.local", cortex_endpoint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, this URI change implies we are 1) renaming the k8s namespace for installation to sensa, but 2) the service name is still cortex-internal (not sensa-internal). Is this the intention?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good catch. The namespace change isn't intentional.
I also feel like as part of the "customer facing" branding, the change of namespace, service names, etc. should be done across the product, but that isn't the scope of this issue right now

)
18 changes: 11 additions & 7 deletions migration.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Note

Users of `cortex-python` should install `sensa-python` instead.
Comment on lines +2 to +3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest repurposing this file to only be a about migrating cortex-python -> sensa-python, because I don't think keeping the migration from cortex-client is useful anymore (if cortex-python is dead, why mention its predecessor?).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we make sure to say that cortex-python is deprecated here (maybe also in the README?)


# Migration steps from `cortex-client` to `cortex-python`

The `cortex-python` library and its optional add-ons are replacing the cortex-client library. The new libraries are more lightweight and use-case focussed. `Cortex-python` may be used for development with or without the add-ons.
The `cortex-python` library and its optional add-ons are replacing the cortex-client library. The new libraries are more lightweight and use-case focussed. `Sensa-python` may be used for development with or without the add-ons.

## Uninstall the previous library (`cortex-client`)

To use the new Cortex libraries, `cortex-python` and `cortex-python-builders` you must uninstall the `cortex-client` library; `cortex-client` and `cortex-python`**cannot** be installed simultaneously in your python environment.
To use the new Sensa libraries, `cortex-python` and `cortex-python-builders` you must uninstall the `cortex-client` library; `cortex-client` and `cortex-python`**cannot** be installed simultaneously in your python environment.

```
> pip uninstall cortex-client
Expand Down Expand Up @@ -49,9 +53,9 @@ To import ManagedContentClient:
```
ConnectionClient can be used to save and retrieve connections.

## Use Cortex magics
## Use Sensa magics

Cortex magics can be used only when the optional `builders` dependency is installed:
Sensa magics can be used only when the optional `builders` dependency is installed:

```
> %reload_ext cortex_builders
Expand All @@ -71,15 +75,15 @@ class to run experiments, save and retrieve your models.
Also, you can use the `action` in the builder class inside client class to build your actions. (Can be used only when optional dependency of builders is installed)

4. `SecretsClient` has been deprecated. There is no equivalent replacement functionality in the python library, but
you can manage secrets through the Cortex Vault in the Cortex Console or via the CLI `cortex variables [command] [options]`.
you can manage secrets through the Sensa Vault in the Sensa Console or via the CLI `cortex variables [command] [options]`.

5. `Message.with_payload()` has been removed. This method was previously deprecated in `cortex-client` v5.5.4.
Instead, use the `Client.message()` method:

```
> from cortex.client import Cortex
> from cortex.client import Sensa

> cortex = Cortex.client()
> cortex = Sensa.client()
> message = cortex.message(payload={'value': 'hello world'})
```

Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions sensa/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Metadata for sensa-python
"""
__title__ = "sensa-python"
__description__ = "Python module for the TecnoTree Sensa Platform"
__url__ = "https://github.com/CognitiveScale/sensa-python"
__version__ = "6.4.0"
__author__ = "TecnoTree"
__author_email__ = "TBD?" # TODO: Add TecnoTree's author email
__license__ = "Apache 2.0"
__copyright__ = "TecnoTree LLC. All Rights Reserved."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure this copyright field matches the copyright statement included throughout the code - see the top of setup.py, sensa/client.py, etc. (this is one reason why I'm not fan of having the License string duplicated in every module).

2 changes: 1 addition & 1 deletion cortex/auth.py → sensa/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class AuthenticationClient(_Client):
"""Client authentication.

:param _Client: :py:class:`cortex.serviceconnector._Client`
:param _Client: :py:class:`sensa.serviceconnector._Client`
:type _Client: _type_
:return: Instance of AuthenticationClient
:rtype: AuthenticationClient
Expand Down
File renamed without changes.
Loading