Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
gnthibault committed Nov 22, 2024
1 parent 6ab5e48 commit 038873b
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 2 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/deploy_gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
# echo "YOUR WIP is ${{ vars.AR_URL }}/${{ vars.IMAGE_NAME }} "
- uses: 'actions/checkout@v4'
- id: 'auth' # The exact debug procedure is described here: https://cloud.google.com/iam/docs/audit-logging/examples-workload-identity#exchange-federated
uses: 'google-github-actions/auth@v2'
uses: 'google-github-actions/auth@v2' # https://github.com/google-github-actions/auth
with:
token_format: access_token
project_id: ${{ vars.PROJECT_ID }}
Expand All @@ -67,7 +67,6 @@ jobs:
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
registry: '${{ vars.AR_REPO_LOCATION }}-docker.pkg.dev'

# - id: 'Set up Cloud SDK'
# uses: 'google-github-actions/setup-gcloud@v2'
# with:
Expand All @@ -78,6 +77,24 @@ jobs:
docker tag ${{ vars.AR_URL }}/${{ vars.IMAGE_NAME }} ${{ vars.AR_URL }}/${{ vars.IMAGE_NAME }}:${{ github.sha }}
#gcloud auth configure-docker ${{ vars.AR_REPO_LOCATION }}-docker.pkg.dev
docker push ${{ vars.AR_URL }}/${{ vars.IMAGE_NAME }}:${{ github.sha }}
- id: 'setup_python'
uses: actions/setup-python@v2
with:
python-version: "3.11.7"
- id: 'install_dependencies'
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
- id: 'migrate_db'
run: |-
curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.13.0/cloud-sql-proxy.linux.amd64
chmod +x cloud-sql-proxy
cloud-sql-proxy --auto-iam-authn ${{ vars.PROJECT_ID }}:${{ vars.CLOUDSQL_LOCATION }}:${{vars.CLOUDSQL_INSTANCE_NAME }}
poetry run python manage.py migrate
- id: 'collect_static'
run: |-
poetry run python manage.py collectstatic
# Deploy comes from https://github.com/google-github-actions/deploy-cloudrun
- id: 'deploy'
uses: 'google-github-actions/deploy-cloudrun@v2'
Expand Down
65 changes: 65 additions & 0 deletions mytom/mytom/remote_observatory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from crispy_forms.layout import Layout
from django import forms

# Locals
from tom_observations.facility import BaseRoboticObservationFacility, BaseRoboticObservationForm

class RemoteObservatoryBaseForm(BaseRoboticObservationForm):
exposure_time = forms.IntegerField()
exposure_count = forms.IntegerField()

def layout(self):
return Layout(
'exposure_time',
'exposure_count'
)


class RemoteObservatory(BaseRoboticObservationFacility):
name = 'RemoteObservatory'
observation_types = [('spectro_lr', 'spectro_hr')]
observation_forms = {
'spectro_lr': RemoteObservatoryBaseForm,
'spectro_hr': RemoteObservatoryBaseForm,
}
SITES = {
# https://trevincaskies.com/#faq
'trevinca_skies': {
'latitude': 42.230175,
'longitude': -6.972704,
'elevation': 800
}
}

def data_products(self, observation_id, product_id=None):
return []

def get_form(self, observation_type):
return self.observation_forms[observation_type]

def get_observation_status(self, observation_id):
return ['IN_PROGRESS']

def get_observation_url(self, observation_id):
return ''

def get_observing_sites(self):
return self.SITES

def get_terminal_observing_states(self):
return ['IN_PROGRESS', 'COMPLETED']

def submit_observation(self, observation_payload):
"""
See https://tom-toolkit.readthedocs.io/en/latest/observing/observation_module.html
The important method here is submit_observation. This method, when implemented fully, will send the
observation payload to the remote observatory and then return a list of observation ids. Those ids will be
stored in the database to be used later, in methods like get_observation_status(self, observation_id).
In our dummy implementation, we simply print out the observation payload and return a single fake id with
return [1].
"""
print(observation_payload)
return [1]

def validate_observation(self, observation_payload):
pass
1 change: 1 addition & 0 deletions mytom/mytom/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@
'tom_observations.facilities.lco.LCOFacility',
'tom_observations.facilities.gemini.GEMFacility',
'tom_observations.facilities.soar.SOARFacility',
'mytom.remote_observatory.RemoteObservatory'
]

TOM_ALERT_CLASSES = [
Expand Down

0 comments on commit 038873b

Please sign in to comment.