Skip to content

Commit

Permalink
PipelineCloud allows token on creation and auto-auths if token is def…
Browse files Browse the repository at this point in the history
…ined (#67)

Closes #66.
  • Loading branch information
bjornaer authored Mar 23, 2022
1 parent bdb365f commit 89a75a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.1.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
Expand Down
13 changes: 10 additions & 3 deletions pipeline/api/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from requests_toolbelt.multipart import encoder
from tqdm import tqdm

from pipeline.schemas.file import FileGet
from pipeline.schemas.data import DataGet
from pipeline.schemas.file import FileGet
from pipeline.schemas.function import FunctionCreate, FunctionGet
from pipeline.schemas.model import ModelCreate, ModelGet
from pipeline.schemas.pipeline import PipelineCreate, PipelineGet, PipelineVariableGet
Expand All @@ -27,9 +27,16 @@ class PipelineCloud:
token: Optional[str]
url: Optional[str]

def __init__(self, url: str = None) -> None:
self.token = os.getenv("PIPELINE_API_TOKEN")
def __init__(self, url: str = None, token: str = None) -> None:
self.token = token or os.getenv("PIPELINE_API_TOKEN")
self.url = url or os.getenv("PIPELINE_API_URL", "https://api.pipeline.ai")
if self.token is not None:
self.authenticate()
else:
print(
"No token set, please set one and invoke",
"PipelineCloud.authenticate() method",
)

def authenticate(self, token: str = None):
"""
Expand Down

0 comments on commit 89a75a0

Please sign in to comment.