Skip to content

Instantly share code, notes, and snippets.

View paul121's full-sized avatar

Paul Weidner paul121

View GitHub Profile
@paul121
paul121 / plan-log-quantities.py
Created April 18, 2024 03:40
Experiment plan log quantity export
import asyncio
from collections import ChainMap
import csv
import time
from farmOS import AsyncFarmClient
from httpx_auth import OAuth2ResourceOwnerPasswordCredentials
from httpx import Limits
hostname = "https://rothamstedfarm.farmos.net"
@paul121
paul121 / data.json
Last active March 12, 2024 00:58
LinkML Project Posts
{
"title": "Post title",
"comment": "Post description",
"files": [
{
"iri": "regen:1111.png",
"name": "Image file name",
"description": "Image description",
"credit": "Paul",
"location": {"wkt": "POINT(1 2)"}
@paul121
paul121 / template-definition.yaml
Last active October 31, 2022 20:06
farmOS platformsh template
# Platform.sh Project Initialization Template
#
# This file defines settings and workflow modifications that allow a git
# repository to be deployed to Platform.sh and its white-label partners. A
# project template can be a fully functioning ready-made application or a
# quick-start point for custom development work.
#
# It contains elements that affect the behaviour upon the initialisation of
# a new project (for example minimal plan sizes) as well as elements that
# allow Platform.sh to present it in a user interface (such as the description
@paul121
paul121 / asset_merge.php
Created August 18, 2022 18:25
Script for merging logs from two assets
<?php
use Drupal\asset\Entity\Asset;
use Drupal\log\Entity\Log;
// Debug flag, leave TRUE to not perform any actions.
$debug = TRUE;
#$debug = FALSE;
// Hosts to to not run this script on.
@paul121
paul121 / asset_dedup.php
Last active August 17, 2022 23:54
Script for detecting duplicate assets & merging log records
<?php
use Drupal\asset\Entity\Asset;
use Drupal\log\Entity\Log;
// Debug flag, leave TRUE to not perform any actions.
$debug = TRUE;
#$debug = FALSE;
// Only query assets created by this username.
@paul121
paul121 / harvest_import.py
Created August 5, 2022 21:13
GSOC Harvest data example
import os
import csv
import argparse
import logging
from datetime import datetime
from time import time
from farmOS import farmOS
### Setup

Setup client

# !pip install farmOS==1.0.0b3
from farmOS import farmOS
hostname="http://localhost"
client = farmOS(hostname, client_id="farm", scope="farm_manager")
current_token = client.authorize()
@paul121
paul121 / jupyterlite_farmospy.ipynb
Last active February 10, 2022 07:29
Example using the farmOS.py classes in jupyterlite.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@paul121
paul121 / aggregator_js_test.js
Last active February 8, 2022 01:01
Example node script for making aggregator requests via farmOS.js
// Import client factory method for node.
const {client} = require('farmos/dist/cjs/farmOS');
// Create a custom auth method to set the api-key header and farm_id query param.
const apiKeyAuth = (request, authOpts = {}) => {
request.interceptors.request.use(
config => {
return {
...config,
headers: {
@paul121
paul121 / aggregator_test.py
Last active January 5, 2022 20:39
farmOS.py aggregator preliminary
import os
from requests.sessions import Session
from farmOS.client_2 import ResourceBase
# Allow testing via http.
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
class AggregatorSession(Session):