Skip to content

Commit

Permalink
feat: trocando credenciais do dagshub
Browse files Browse the repository at this point in the history
  • Loading branch information
heltonricardo committed Dec 21, 2023
1 parent 7ef0945 commit cf24150
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ jobs:
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Set Environment Variables
run: echo "DAGSHUB_TOKEN=${{ secrets.DAGSHUB_TOKEN }}" >> $GITHUB_ENV
run: |
echo "MLFLOW_TRACKING_URI=${{ secrets.MLFLOW_TRACKING_URI }}" >> $GITHUB_ENV
echo "MLFLOW_TRACKING_USERNAME=${{ secrets.MLFLOW_TRACKING_USERNAME }}" >> $GITHUB_ENV
echo "MLFLOW_TRACKING_PASSWORD=${{ secrets.MLFLOW_TRACKING_PASSWORD }}" >> $GITHUB_ENV
echo "MLFLOW_TRACKING_MODEL=${{ secrets.MLFLOW_TRACKING_MODEL }}" >> $GITHUB_ENV
- name: Test files
run: pytest src/test_train.py
Expand Down
12 changes: 5 additions & 7 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,16 @@ def load_model():
None
"""
print("reading model...")
MLFLOW_TRACKING_URI = \
"https://dagshub.com/renansantosmendes/mlops-ead.mlflow"
MLFLOW_TRACKING_USERNAME = "renansantosmendes"
MLFLOW_TRACKING_PASSWORD = "b63baf8c662a23fa00deb74ba86600278769e5dd"
os.environ["MLFLOW_TRACKING_USERNAME"] = MLFLOW_TRACKING_USERNAME
os.environ["MLFLOW_TRACKING_PASSWORD"] = MLFLOW_TRACKING_PASSWORD
MLFLOW_TRACKING_URI = os.getenv("MLFLOW_TRACKING_URI")
MLFLOW_TRACKING_USERNAME = os.getenv("MLFLOW_TRACKING_USERNAME")
MLFLOW_TRACKING_PASSWORD = os.getenv("MLFLOW_TRACKING_PASSWORD")
MLFLOW_TRACKING_MODEL = os.getenv("MLFLOW_TRACKING_MODEL")
print("setting mlflow...")
mlflow.set_tracking_uri(MLFLOW_TRACKING_URI)
print("creating client..")
client = mlflow.MlflowClient(tracking_uri=MLFLOW_TRACKING_URI)
print("getting registered model...")
registered_model = client.get_registered_model("fetal_health")
registered_model = client.get_registered_model(MLFLOW_TRACKING_MODEL)
print("read model...")
run_id = registered_model.latest_versions[-1].run_id
logged_model = f"runs:/{run_id}/model"
Expand Down
13 changes: 4 additions & 9 deletions src/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ def config_mlflow():
variables to provide authentication for accessing the MLflow tracking
server.
Sets the MLflow tracking URI to
'https://dagshub.com/renansantosmendes/mlops-ead.mlflow'
to specify the location where the experiment data will be logged.
Sets the MLflow tracking URI to specify the location where the experiment
data will be logged.
Enables autologging of TensorFlow models by calling
`mlflow.tensorflow.autolog()`.
Expand All @@ -126,12 +125,8 @@ def config_mlflow():
Returns:
None
"""
os.environ["MLFLOW_TRACKING_USERNAME"] = "renansantosmendes"
os.environ["MLFLOW_TRACKING_PASSWORD"] = \
"6d730ef4a90b1caf28fbb01e5748f0874fda6077"
mlflow.set_tracking_uri(
"https://dagshub.com/renansantosmendes/mlops-ead.mlflow"
)

mlflow.set_tracking_uri(os.getenv("MLFLOW_TRACKING_URI"))

mlflow.tensorflow.autolog(
log_models=True, log_input_examples=True, log_model_signatures=True
Expand Down

0 comments on commit cf24150

Please sign in to comment.