Skip to content

Commit 36dec66

Browse files
authored
Merge branch 'develop' into release-notes/2.8.4
2 parents 5c1d96f + 9022784 commit 36dec66

File tree

115 files changed

+4578
-691
lines changed

Some content is hidden

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

115 files changed

+4578
-691
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Publish Docs"
2+
3+
on:
4+
# Auto-trigger this workflow on tag creation
5+
push:
6+
tags:
7+
- 'v*.*.*'
8+
# Auto-trigger this workflow on merge to main changes in docs/** folder
9+
pull_request_target:
10+
types:
11+
- closed
12+
branches:
13+
- main
14+
paths:
15+
- 'docs/**'
16+
17+
env:
18+
RTDS_ADS_PROJECT: https://readthedocs.org/api/v3/projects/accelerated-data-science
19+
RTDS_ADS_TOKEN: ${{ secrets.RTDS_ADS_TOKEN }}
20+
21+
jobs:
22+
build-n-publish:
23+
name: Build and publish Docs 📖 to Readthedocs
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: When PR ✅ merged - Trigger Readthedocs build
28+
if: github.event_name == 'pull_request_target' && github.event.pull_request.merged == true
29+
run: |
30+
curl \
31+
-X POST \
32+
-H "Authorization: Token $RTDS_ADS_TOKEN" $RTDS_ADS_PROJECT/versions/latest/builds/
33+
- name: When tag 🏷️ pushed - Trigger Readthedocs build
34+
if: github.event_name == 'push' && startsWith(github.ref_name, 'v')
35+
run: |
36+
# add 10 minutes wait time for readthedocs see freshly created tag
37+
sleep 10m
38+
curl \
39+
-X POST \
40+
-H "Authorization: Token $RTDS_ADS_TOKEN" $RTDS_ADS_PROJECT/versions/${{ github.ref_name }}/builds/

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
name: tests/unitary/default_setup/**
22

33
on:
4-
push:
4+
pull_request:
55
branches:
66
- main
7-
- 'release/**'
7+
- "release/**"
88
- develop
99
paths:
10-
- 'ads/**'
10+
- "ads/**"
1111
- setup.py
12-
- '**requirements.txt'
13-
- '!docs/**'
14-
15-
pull_request:
12+
- "**requirements.txt"
13+
- .github/workflows/run-unittests.yml
14+
- .github/workflows/run-unittests-default_setup.yml
1615

1716
# Cancel in progress workflows on pull_requests.
1817
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
@@ -77,7 +76,6 @@ jobs:
7776
timeout-minutes: 15
7877
shell: bash
7978
env:
80-
NB_SESSION_COMPARTMENT_OCID: ocid1.compartment.oc1.<unique_ocid>
8179
NoDependency: True
8280
run: |
8381
set -x # print commands that are executed

.github/workflows/run-unittests.yml

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
name: tests/unitary/**
22

33
on:
4-
push:
4+
pull_request:
55
branches:
66
- main
7-
- 'release/**'
7+
- "release/**"
88
- develop
99
paths:
10-
- 'ads/**'
10+
- "ads/**"
1111
- setup.py
12-
- '**requirements.txt'
13-
- '!docs/**'
14-
15-
pull_request:
12+
- "**requirements.txt"
13+
- .github/workflows/run-unittests.yml
14+
- .github/workflows/run-unittests-default_setup.yml
1615

1716
# Cancel in progress workflows on pull_requests.
1817
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
@@ -88,22 +87,21 @@ jobs:
8887
shell: bash
8988
run: |
9089
set -x # print commands that are executed
91-
90+
9291
sudo apt-get install libkrb5-dev graphviz
9392
$CONDA/bin/conda init
9493
source /home/runner/.bashrc
95-
94+
9695
pip install -r dev-requirements.txt
9796
9897
- name: "Run unitary tests folder with maximum ADS dependencies"
9998
timeout-minutes: 60
10099
shell: bash
101100
env:
102-
NB_SESSION_COMPARTMENT_OCID: ocid1.compartment.oc1.<unique_ocid>
103101
CONDA_PREFIX: /usr/share/miniconda
104102
run: |
105103
set -x # print commands that are executed
106-
104+
107105
# Setup project and tests folder for cov reports to not be overwritten by another parallel step
108106
if [[ ! -z "${{ matrix.cov-reports }}" ]]; then
109107
mkdir -p cov-${{ matrix.name }}
@@ -112,7 +110,7 @@ jobs:
112110
ln -s ../ads ads
113111
ln -s ../.coveragerc .coveragerc
114112
fi
115-
113+
116114
# Run tests
117115
python -m pytest -v -p no:warnings --durations=5 \
118116
-n auto --dist loadfile ${{ matrix.cov-reports }} \
@@ -148,41 +146,41 @@ jobs:
148146
- name: "Calculate overall coverage"
149147
run: |
150148
set -x # print commands that are executed
151-
149+
152150
# Prepare default cov body text
153151
COV_BODY_INTRO="📌 Overall coverage:\n\n"
154152
echo COV_BODY="$COV_BODY_INTRO No success to gather report. 😿" >> $GITHUB_ENV
155-
153+
156154
# Combine coverage files
157155
pip install coverage
158156
coverage combine cov-reports-unitary/.coverage cov-reports-model/.coverage
159-
157+
160158
# Make html report
161159
coverage html
162-
160+
163161
# Calculate overall coverage and update body message
164162
COV=$(grep -E 'pc_cov' htmlcov/index.html | cut -d'>' -f 2 | cut -d'%' -f 1)
165163
if [[ ! -z $COV ]]; then
166-
if [[ $COV < 50 ]]; then COLOR=red; elif [[ $COV < 80 ]]; then COLOR=yellow; else COLOR=green; fi
164+
if [[ $COV -lt 50 ]]; then COLOR=red; elif [[ $COV -lt 80 ]]; then COLOR=yellow; else COLOR=green; fi
167165
echo COV_BODY="$COV_BODY_INTRO ![Coverage-$COV%](https://img.shields.io/badge/coverage-$COV%25-$COLOR)" >> $GITHUB_ENV
168166
fi
169167
170168
- name: "Calculate coverage diff"
171169
if: always()
172170
run: |
173171
set -x # print commands that are executed
174-
172+
175173
# Prepare default diff body text
176174
DIFF_BODY_INTRO="📌 Cov diff with **${{ env.COMPARE_BRANCH }}**:\n\n"
177-
echo DIFF_BODY="$BODY_INTRO No success to gather report. 😿" >> $GITHUB_ENV
178-
175+
echo DIFF_BODY="$DIFF_BODY_INTRO No success to gather report. 😿" >> $GITHUB_ENV
176+
179177
# Prepare file paths to coverage xml files
180178
# Filenames taken from job.test last step with name - "Save coverage files"
181179
FILE1="cov-reports-unitary/coverage.xml"; [[ ! -f $FILE1 ]] && FILE1=""
182180
FILE2="cov-reports-model/coverage.xml"; [[ ! -f $FILE2 ]] && FILE2=""
183181
echo "FILE1=$FILE1" >> $GITHUB_ENV
184182
echo "FILE2=$FILE2" >> $GITHUB_ENV
185-
183+
186184
# Calculate coverage diff and update body message
187185
pip install diff_cover
188186
diff-cover $FILE1 $FILE2 --compare-branch=origin/${{ env.COMPARE_BRANCH }}
@@ -193,7 +191,7 @@ jobs:
193191
--compare-branch=origin/${{ env.COMPARE_BRANCH }} | grep "No lines");
194192
echo DIFF_BODY="$DIFF_BODY_INTRO $DIFF_INFO">> $GITHUB_ENV
195193
else
196-
if [[ $DIFF < 50 ]]; then COLOR=red; elif [[ $DIFF < 80 ]]; then COLOR=yellow; else COLOR=green; fi
194+
if [[ $DIFF -lt 50 ]]; then COLOR=red; elif [[ $DIFF -lt 80 ]]; then COLOR=yellow; else COLOR=green; fi
197195
echo DIFF_BODY="$DIFF_BODY_INTRO ![Coverage-$DIFF%](https://img.shields.io/badge/coverage-$DIFF%25-$COLOR)" >> $GITHUB_ENV
198196
fi
199197

.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))

ads/common/object_storage_details.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,20 @@ def is_valid_uri(uri: str) -> bool:
121121
"It must follow the pattern `oci://<bucket_name>@<namespace>/<prefix>`."
122122
)
123123
return True
124+
125+
@staticmethod
126+
def is_oci_path(uri: str = None) -> bool:
127+
"""Check if the given path is oci object storage uri.
128+
129+
Parameters
130+
----------
131+
uri: str
132+
The URI of the target.
133+
134+
Returns
135+
-------
136+
bool: return True if the path is oci object storage uri.
137+
"""
138+
if not uri:
139+
return False
140+
return uri.startswith("oci://")

0 commit comments

Comments
 (0)