Data Analytics
30.9K subscribers
552 photos
21 videos
48 files
374 links
Dive into the world of Data Analytics – uncover insights, explore trends, and master data-driven decision making.

Admin: @HusseinSheikho || @Hussein_Sheikho
Download Telegram
Cheat Sheet: Docker Commands and Main Components

#DevOps #Docker

https://t.iss.one/Ebooks2023 😎
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘6
πŸ“Œ Kubernetes Cheat Sheet πŸ“Œ

The 31 Commands You Need To Know πŸ‘‡

#DevOps #DevOpsCommunity #Kubernetes #K8S

USEFUL CHANNELS FOR YOU
πŸ‘7❀2
πŸ“Œ How to Deploy a Kubernetes App on AWS EKS

✍️ Ijeoma Igboagu
🏷️ #Devops
Forwarded from Learn Python Coding
Data validation with Pydantic! 🐍✨

In the early stages of development, data validation usually doesn't cause problems. In many Python projects, validation initially looks simple:

if not isinstance(age, int):
raise ValueError("age must be an int")

But then come email, JSON from APIs, query parameters, nested objects, configs, nullable fields, and type conversion. At some point, the code turns into a set of if/else and manual checks.

For such tasks, Pydantic is often used. Installation:

pip install pydantic
pip install "pydantic[email]"

Create a model:

from pydantic import BaseModel

class User(BaseModel):
name: str
age: int

Now the data is validated automatically:

user = User(
name="Alex",
age="30"
)

print(user.age)
print(type(user.age))

The result:
30
<class 'int'>

Pydantic will automatically convert the string "30" to an int. If you pass an incorrect value, you'll get a ValidationError:

User(
name="Alex",
age="test"
)

This is especially convenient when working with APIs, JSON, query parameters, and incoming data from outside.

A common production case is checking email:

from pydantic import BaseModel, EmailStr

class User(BaseModel):
email: EmailStr

User(email="[email protected]")

If the email is invalid, Pydantic will throw a ValidationError. You can set default values:

from pydantic import BaseModel

class Config(BaseModel):
host: str = "localhost"
port: int = 5432

And allow None:

from pydantic import BaseModel

class User(BaseModel):
nickname: str | None = None

This field becomes optional. A practical example is processing an API response:

from pydantic import BaseModel

class Product(BaseModel):
id: int
title: str
price: float

data = {
"id": "1",
"title": "Keyboard",
"price": "99.5"
}

product = Product(**data)

print(product)

The types will be automatically converted. For nested model structures, you can combine:

from pydantic import BaseModel

class Address(BaseModel):
city: str
zip_code: str

class User(BaseModel):
name: str
address: Address

user = User(
name="Alex",
address={
"city": "Berlin",
"zip_code": "10115"
}
)

print(user)

The nested object will also be validated. Serialization in Pydantic v2:

print(user.model_dump())
print(user.model_dump_json())

Pydantic is actively used in FastAPI, ETL, microservices, data pipelines, and API clients.

For working with environment variables in Pydantic v2, a separate package is usually used:

pip install pydantic-settings

It's important to understand: Pydantic is not an ORM and does not replace business logic. Its task is to validate data, convert types, and describe schemas.

πŸ”₯ Pydantic significantly reduces the amount of manual data validation and makes processing incoming structures more predictable.

#Python #Pydantic #DataValidation #FastAPI #Coding #DevOps

✨ Join Best TG Channels https://t.iss.one/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
❀6
Exporting the model from PyTorch to the universal ONNX format for independent inference πŸš€

Deploying PyTorch models in production often requires installing a large framework and relying on a Python environment. The ONNX (Open Neural Network Exchange) format converts the computation graph into an intermediate binary format suitable for running on any device and programming language. We will export the PyTorch neural network and run its inference using the lightweight ONNX Runtime. πŸ› 

To export and run the neural network, we will install the PyTorch framework, the ONNX library, and the cross-platform ONNX Runtime engine.

pip install torch onnx onnxruntime


The packages for converting and high-performance execution of graphs have been successfully installed. βœ…

We will write a Python script that creates a test PyTorch model, exports it to a .onnx file, and immediately performs a verification of the output.

import torch, torch.nn as nn, onnxruntime as ort, numpy as np

model = nn.Sequential(nn.Linear(10, 5), nn.ReLU())
x = torch.randn(1, 10)
torch.onnx.export(model, x, "model.onnx", input_names=["input"], output_names=["output"])

session = ort.InferenceSession("model.onnx")
res = session.run(None, {"input": x.numpy()})
print("ONNX Output shape:", res[0].shape)


The model graph has been successfully serialized into a binary file, and the runtime performed the prediction without involving PyTorch. πŸ“¦

# verification (checks the correctness and structure of the saved ONNX model)
python3 -c "import onnx; model = onnx.load('model.onnx'); onnx.checker.check_model(model); print('ONNX Model Status: Valid')"


Expected output: ONNX Model Status: Valid

# cleanup (deletes the generated model file and cleans up binaries)
rm -f model.onnx


Converting neural networks to ONNX allows you to decouple inference from Python and run models in C++, Rust, Go, or directly in a web browser. Be sure to specify the names of the input and output tensors when exporting to simplify integration with the service. πŸ’»

#PyTorch #ONNX #MachineLearning #DeepLearning #AI #DevOps

✨ Join Best TG Channels https://t.iss.one/addlist/0f6vfFbEMdAwODBk

⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
❀1
πŸ”₯ Free IT & Dev Study Kits – 2026 Prep, No Signup

If you’re prepping for cloud, dev, or AI roles this year, these free kits cover the gaps most people skip β€” cert basics, hands-on labs, and mock exams. No signup traps, no hidden fees.

πŸ“˜ Cert E-Book β€” covers Cisco & AWS fundamentals, good for first-time cert takers
β†’ https://bit.ly/4yrk1Ti

πŸͺœ Online Free Course β€” structured path, works as a refresher before exams
β†’ https://bit.ly/4hUprRP

☁️ Free AI Materials β€” LLM basics to fine-tuning practice notebooks
β†’ https://bit.ly/4yt1iXy

πŸ“Š Cloud Study Guide β€” cheat-sheet style, handy for interview prep
β†’ https://bit.ly/4el4Eod

🧠 Free Mock Exam β€” test yourself before booking the real thing
β†’ https://bit.ly/4sbWlkl

πŸ“Œ Save this or forward it to your dev/study group β€” good resources are worth sharing. πŸ’ͺ

🌐 Community: https://chat.whatsapp.com/CS7VOvQCLZG5BJPazBGm1v
πŸ“² Personalized help:
https://wa.link/xd2fu6
#Python #Cloud #AWS #Cisco #AI #MachineLearning #DevOps #ITCertification #FreeResources #TechCareers
❀2