Skip to content

Commit

Permalink
chore: Remove SCW_ as it only for CI purpose into scaleway
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Jan 27, 2024
1 parent bd86a70 commit 012d612
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
17 changes: 11 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ SCW_REGION="fr-par"
SCW_ACCESS_KEY_ID=
SCW_SECRET_ACCESS_KEY=
SCW_REGISTRY="registry.fr-par.scw.cloud"
SCW_S3_ENDPOINT="https://s3.fr-par.scw.cloud"
SCW_S3_BUCKET='astrolabe-expeditions-data'
SCW_SQS_ENDPOINT="https://sqs.mnq.fr-par.scaleway.com"
SCW_SQS_ID=
SCW_SQS_SECRET=
SCW_SQS_QUEUE_URL=

S3_ENDPOINT="https://s3.fr-par.scw.cloud"
S3_BUCKET='astrolabe-expeditions-data'
S3_ID=
S3_SECRET=

SQS_REGION="fr-par"
SQS_ENDPOINT="https://sqs.mnq.fr-par.scaleway.com"
SQS_ID=
SQS_SECRET=
SQS_QUEUE_URL=
8 changes: 4 additions & 4 deletions src/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

def connect_to_s3():
s3 = boto3.client('s3',
endpoint_url = os.environ['SCW_S3_ENDPOINT'],
endpoint_url = os.environ['S3_ENDPOINT'],
config = boto3.session.Config(signature_version = 's3v4'),
aws_access_key_id = os.environ['SCW_ACCESS_KEY_ID'],
aws_secret_access_key = os.environ['SCW_SECRET_ACCESS_KEY'],
aws_access_key_id = os.environ['S3_ID'],
aws_secret_access_key = os.environ['S3_SECRET'],
aws_session_token = None)
return s3

Expand Down Expand Up @@ -44,7 +44,7 @@ def process_file(file_id):
#insertion de lecture et traitement du dataset
s3 = connect_to_s3()
Key= "sensors/" + str(information["sensor_id"]) + "/" + file_id + ".csv"
response = s3.get_object(Bucket=os.environ['SCW_S3_BUCKET'], Key = Key)
response = s3.get_object(Bucket=os.environ['S3_BUCKET'], Key = Key)
content = response['Body'].read().decode('utf-8')
data = pd.read_csv(io.StringIO(content), delimiter=";")
dataset = run(data)
Expand Down
10 changes: 0 additions & 10 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,8 @@

DEFAULT_PORT = "8080"


app = Flask(__name__)

def connect_to_s3():
s3 = boto3.client('s3',
endpoint_url = os.environ['SCW_ENDPOINT'],
config = boto3.session.Config(signature_version = 's3v4'),
aws_access_key_id = os.environ['SCW_ACCESS_KEY_ID'],
aws_secret_access_key = os.environ['SCW_SECRET_ACCESS_KEY'],
aws_session_token = None)
return s3

@app.errorhandler(404)
def resource_not_found(e):
return jsonify(error=str(e)), 404
Expand Down
10 changes: 5 additions & 5 deletions src/sqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

# Create SQS client
sqs = boto3.resource('sqs',
endpoint_url=os.environ['SCW_SQS_ENDPOINT'],
aws_access_key_id=os.environ['SCW_SQS_ID'],
aws_secret_access_key=os.environ['SCW_SQS_SECRET'],
region_name=os.environ['SCW_REGION'])
endpoint_url=os.environ['SQS_ENDPOINT'],
aws_access_key_id=os.environ['SQS_ID'],
aws_secret_access_key=os.environ['SQS_SECRET'],
region_name=os.environ['SQS_REGION'])

queue = sqs.Queue(url=os.environ['SCW_SQS_QUEUE_URL'])
queue = sqs.Queue(url=os.environ['SQS_QUEUE_URL'])

messages = queue.receive_messages(
MaxNumberOfMessages=1,
Expand Down

0 comments on commit 012d612

Please sign in to comment.