Skip to content

Commit 7ec06a8

Browse files
authored
Merge branch 'develop' into ODSC-42082/ads_opctl_init_docs
2 parents c54643e + 79044ea commit 7ec06a8

File tree

86 files changed

+3772
-535
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+3772
-535
lines changed

.github/workflows/run-unittests-default_setup.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ on:
44
pull_request:
55
branches:
66
- main
7-
- 'release/**'
7+
- "release/**"
88
- develop
99
paths:
10-
- 'ads/**'
10+
- "ads/**"
1111
- setup.py
12-
- '**requirements.txt'
12+
- "**requirements.txt"
13+
- .github/workflows/run-unittests.yml
14+
- .github/workflows/run-unittests-default_setup.yml
1315

1416
# Cancel in progress workflows on pull_requests.
1517
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
@@ -74,7 +76,6 @@ jobs:
7476
timeout-minutes: 15
7577
shell: bash
7678
env:
77-
NB_SESSION_COMPARTMENT_OCID: ocid1.compartment.oc1.<unique_ocid>
7879
NoDependency: True
7980
run: |
8081
set -x # print commands that are executed

.github/workflows/run-unittests.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ on:
44
pull_request:
55
branches:
66
- main
7-
- 'release/**'
7+
- "release/**"
88
- develop
99
paths:
10-
- 'ads/**'
10+
- "ads/**"
1111
- setup.py
12-
- '**requirements.txt'
12+
- "**requirements.txt"
13+
- .github/workflows/run-unittests.yml
14+
- .github/workflows/run-unittests-default_setup.yml
1315

1416
# Cancel in progress workflows on pull_requests.
1517
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
@@ -85,22 +87,21 @@ jobs:
8587
shell: bash
8688
run: |
8789
set -x # print commands that are executed
88-
90+
8991
sudo apt-get install libkrb5-dev graphviz
9092
$CONDA/bin/conda init
9193
source /home/runner/.bashrc
92-
94+
9395
pip install -r dev-requirements.txt
9496
9597
- name: "Run unitary tests folder with maximum ADS dependencies"
9698
timeout-minutes: 60
9799
shell: bash
98100
env:
99-
NB_SESSION_COMPARTMENT_OCID: ocid1.compartment.oc1.<unique_ocid>
100101
CONDA_PREFIX: /usr/share/miniconda
101102
run: |
102103
set -x # print commands that are executed
103-
104+
104105
# Setup project and tests folder for cov reports to not be overwritten by another parallel step
105106
if [[ ! -z "${{ matrix.cov-reports }}" ]]; then
106107
mkdir -p cov-${{ matrix.name }}
@@ -109,7 +110,7 @@ jobs:
109110
ln -s ../ads ads
110111
ln -s ../.coveragerc .coveragerc
111112
fi
112-
113+
113114
# Run tests
114115
python -m pytest -v -p no:warnings --durations=5 \
115116
-n auto --dist loadfile ${{ matrix.cov-reports }} \
@@ -145,18 +146,18 @@ jobs:
145146
- name: "Calculate overall coverage"
146147
run: |
147148
set -x # print commands that are executed
148-
149+
149150
# Prepare default cov body text
150151
COV_BODY_INTRO="📌 Overall coverage:\n\n"
151152
echo COV_BODY="$COV_BODY_INTRO No success to gather report. 😿" >> $GITHUB_ENV
152-
153+
153154
# Combine coverage files
154155
pip install coverage
155156
coverage combine cov-reports-unitary/.coverage cov-reports-model/.coverage
156-
157+
157158
# Make html report
158159
coverage html
159-
160+
160161
# Calculate overall coverage and update body message
161162
COV=$(grep -E 'pc_cov' htmlcov/index.html | cut -d'>' -f 2 | cut -d'%' -f 1)
162163
if [[ ! -z $COV ]]; then
@@ -168,18 +169,18 @@ jobs:
168169
if: always()
169170
run: |
170171
set -x # print commands that are executed
171-
172+
172173
# Prepare default diff body text
173174
DIFF_BODY_INTRO="📌 Cov diff with **${{ env.COMPARE_BRANCH }}**:\n\n"
174175
echo DIFF_BODY="$DIFF_BODY_INTRO No success to gather report. 😿" >> $GITHUB_ENV
175-
176+
176177
# Prepare file paths to coverage xml files
177178
# Filenames taken from job.test last step with name - "Save coverage files"
178179
FILE1="cov-reports-unitary/coverage.xml"; [[ ! -f $FILE1 ]] && FILE1=""
179180
FILE2="cov-reports-model/coverage.xml"; [[ ! -f $FILE2 ]] && FILE2=""
180181
echo "FILE1=$FILE1" >> $GITHUB_ENV
181182
echo "FILE2=$FILE2" >> $GITHUB_ENV
182-
183+
183184
# Calculate coverage diff and update body message
184185
pip install diff_cover
185186
diff-cover $FILE1 $FILE2 --compare-branch=origin/${{ env.COMPARE_BRANCH }}

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-ast
6+
- id: check-docstring-first
7+
exclude: ^tests/
8+
- id: check-json
9+
- id: check-merge-conflict
10+
- id: check-yaml
11+
args: ['--allow-multiple-documents']
12+
- id: detect-private-key
13+
- id: end-of-file-fixer
14+
- id: pretty-format-json
15+
args: ['--autofix']
16+
- id: trailing-whitespace
17+
- repo: https://github.com/psf/black
18+
rev: 22.12.0
19+
hooks:
20+
- id: black
21+
- repo: https://github.com/pre-commit/pygrep-hooks
22+
rev: v1.9.0
23+
hooks:
24+
- id: rst-backticks
25+
- id: rst-inline-touching-normal
26+
27+
exclude: ^(docs/)

ads/__init__.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,8 @@ def _set_test_mode(mode=False):
122122

123123

124124
def hello():
125-
"""
126-
Imports Pandas, sets the documentation mode, and prints a fancy "Hello".
127-
"""
128-
import pandas
129-
130-
global documentation_mode
131-
global debug_mode
125+
import oci
126+
import ocifs
132127

133128
print(
134129
f"""
@@ -139,11 +134,11 @@ def hello():
139134
| || / |
140135
o oo-o o--o
141136
142-
ADS SDK version: {__version__}
143-
Pandas version: {pandas.__version__}
144-
Debug mode: {debug_mode}
145-
"""
146-
)
137+
ads v{__version__}
138+
oci v{oci.__version__}
139+
ocifs v{ocifs.__version__}
140+
141+
""")
147142

148143

149144
configure_plotting()

ads/ads

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export OCI_PYTHON_SDK_NO_SERVICE_IMPORTS=1
2-
python -m ads.cli "$@"
2+
python3 -m ads.cli "$@"

ads/cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33

44
# Copyright (c) 2021, 2022 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6+
from ads.common import logger
7+
import traceback
8+
69
try:
710
import click
811
import ads.opctl.cli
912
import ads.jobs.cli
1013
import ads.pipeline.cli
1114
import os
1215
import json
13-
except:
16+
except Exception as ex:
1417
print(
15-
"Please run `pip install oracle-ads[opctl]` to install the required dependencies for ADS CLI"
18+
"Please run `pip install oracle-ads[opctl]` to install "
19+
"the required dependencies for ADS CLI."
1620
)
21+
logger.debug(ex)
22+
logger.debug(traceback.format_exc())
1723
exit()
1824

1925

ads/common/extended_enum.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77

88
from abc import ABCMeta
9+
from enum import Enum
910

1011

1112
class ExtendedEnumMeta(ABCMeta):
@@ -15,13 +16,20 @@ class ExtendedEnumMeta(ABCMeta):
1516
-------
1617
values(cls) -> list:
1718
Gets the list of class attributes.
19+
20+
Examples
21+
--------
22+
>>> class TestEnum(str, metaclass=ExtendedEnumMeta):
23+
... KEY1 = "value1"
24+
... KEY2 = "value2"
25+
>>> print(TestEnum.KEY1) # "value1"
1826
"""
1927

2028
def __contains__(cls, value):
2129
return value and value.lower() in tuple(value.lower() for value in cls.values())
2230

2331
def values(cls) -> list:
24-
"""Gets the list of class attributes.
32+
"""Gets the list of class attributes values.
2533
2634
Returns
2735
-------
@@ -31,3 +39,35 @@ def values(cls) -> list:
3139
return tuple(
3240
value for key, value in cls.__dict__.items() if not key.startswith("_")
3341
)
42+
43+
def keys(cls) -> list:
44+
"""Gets the list of class attributes names.
45+
46+
Returns
47+
-------
48+
list
49+
The list of class attributes names.
50+
"""
51+
return tuple(
52+
key for key, value in cls.__dict__.items() if not key.startswith("_")
53+
)
54+
55+
56+
class ExtendedEnum(Enum):
57+
"""The base class to extend functionality of a generic Enum.
58+
59+
Examples
60+
--------
61+
>>> class TestEnum(ExtendedEnumMeta):
62+
... KEY1 = "value1"
63+
... KEY2 = "value2"
64+
>>> print(TestEnum.KEY1.value) # "value1"
65+
"""
66+
67+
@classmethod
68+
def values(cls):
69+
return sorted(map(lambda c: c.value, cls))
70+
71+
@classmethod
72+
def keys(cls):
73+
return sorted(map(lambda c: c.name, cls))

0 commit comments

Comments
 (0)