Skip to content

Instantly share code, notes, and snippets.

View lotif's full-sized avatar
👻

Marcelo Lotif lotif

👻
View GitHub Profile
@lotif
lotif / upload_and_deploy_new_model_version.py
Last active August 25, 2024 22:10
Upload and deploy new model version to Vertex AI endpoint
import sys
import logging
from google.cloud import aiplatform
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s: %(message)s")
logger = logging.getLogger(__name__)
model_id = sys.argv[1]
artifact_uri = sys.argv[2]
{
"IamFleetRole": "arn:aws:iam::<aws-account-id>:role/<fleet-role-name>",
"AllocationStrategy": "lowestPrice",
"TargetCapacity": 2,
"SpotPrice": "0.105",
"ValidUntil": "2050-01-01T00:00:00Z",
"TerminateInstancesWithExpiration": false,
"LaunchSpecifications": [
{
"ImageId": "<ami-id-for-your-region>",
@lotif
lotif / hello-world-task-def.json
Last active March 7, 2018 18:23
simplified task definition
{
"family": "hello-world-task-def",
"containerDefinitions": [
{
"name": "hello-world",
"image": "<aws-account-id>.dkr.ecr.us-east-1.amazonaws.com/hello-world",
"memoryReservation": 1024,
"command": ["python", "/home/ubuntu/workspace/keras-docker-hello-world/hello_world.py"]
}
]
@lotif
lotif / integrationTests.js
Last active June 17, 2017 02:05
integration test with promises
it('should change the text on click', async () => {
http.get.mockImplementation(() => Promise.resolve({ body: 'the-return-of-my-get-request' }));
const sut = mount(
<Provider store={store}>
<MyComponent />
</Provider>
);
sut.find('div').simulate('click');
@lotif
lotif / utils.js
Created June 16, 2017 21:50
flushAllPromises
/* Async function that will finish execution after all promises have been finished
* Usage:
* it('...', async () =. {
* // mount component
* // execute actions
* await flushAllPromises();
* // execute assertions for async actions
* });
*/
export function flushAllPromises() {
@lotif
lotif / integrationTests.js
Last active June 17, 2017 02:05
testing http calls
// to mock a whole imported dependency, do this
jest.mock('my-http-client');
import http from 'my-http-client';
// ...
it('should change the text on click', () => {
http.get.mockImplementation({ body: 'the-return-of-my-get-request' });
const sut = mount(
<Provider store={store}>
@lotif
lotif / integrationTests.js
Last active June 17, 2017 02:06
more tests
// To test if the action producer has dispatched the correct action
expect(dispatchSpy).toBeCalledWith({ type: 'DIV_HAS_BEEN_CLICKED' });
// To test if the actual data on the reducer has changed
expect(store.getState().myReducer.divText).toEqual('new text');
@lotif
lotif / integrationTests.js
Last active June 17, 2017 02:06
test component integration tests
it('should change the text on click', () => {
const sut = mount(
<Provider store={store}>
<MyComponent />
</Provider>
);
sut.find('div').simulate('click');
expect(sut.find('div').prop('children')).toEqual('new text');
@lotif
lotif / integrationTests.js
Last active June 17, 2017 02:13
before each for integration tests
describe('integration tests', () => {
let store;
let dispatchSpy;
let router;
beforeEach(() => {
router = {
params: { myParam: 'any-params-you-have' },
};
({ store, dispatchSpy } = setupIntegrationTest({ myReducer }, router));
@lotif
lotif / utils.js
Last active June 4, 2018 14:10
setupIntegrationTest utils function
import { applyMiddleware, combineReducers, createStore } from 'redux';
import thunk from 'redux-thunk';
import { routerStateReducer } from 'redux-router';
/* Sets up basic variables to be used by integration tests
* Params:
* reducers: should be an object with all the reducers your page uses
* initialRouterState: an optional object to set as the initial state for the router
* Returns: